Completed
Push — 14.2 ( 1730cb...8c75f3 )
by Ralf
73:29 queued 51:28
created
doc/rpm-build/checkout-build-archives.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,6 +464,7 @@  discard block
 block discarded – undo
464 464
  *
465 465
  * @param string $name
466 466
  * @param string $value =null value to use, default $config[$name]
467
+ * @return string
467 468
  */
468 469
 function config_translate($name, $value=null)
469 470
 {
@@ -1194,7 +1195,7 @@  discard block
 block discarded – undo
1194 1195
  * Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose)
1195 1196
  *
1196 1197
  * @param string $cmd
1197
- * @param array& $output=null $output of command, only if !$verbose !!!
1198
+ * @param array& $output $output of command, only if !$verbose !!!
1198 1199
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1199 1200
  * @return int exit code of $cmd
1200 1201
  */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	curl_setopt($c, CURLOPT_URL, $url);
442 442
 
443 443
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
444
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
444
+	if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
445 445
 
446 446
 	if (($response = curl_exec($c)) === false)
447 447
 	{
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
675 675
 			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
676 676
 		{
677
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
677
+			if ($verbose) echo "revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
678 678
 			return (int)$log['revision'];
679 679
 		}
680 680
 	}
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			if ($content != $content_was)
756 756
 			{
757 757
 				file_put_contents($path,$content);
758
-				if ($verbose) echo "Updated $path\n";
758
+				if ($verbose) echo "updated $path\n";
759 759
 				++$n;
760 760
 			}
761 761
 		}
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	}
884 884
 	foreach($config['types'] as $type)
885 885
 	{
886
-		echo "Creating $type archives\n";
886
+		echo "creating $type archives\n";
887 887
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
888 888
 
889 889
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 
1006 1006
 	if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#')
1007 1007
 	{
1008
-		echo "Running $cmd\n";
1008
+		echo "running $cmd\n";
1009 1009
 		run_cmd($cmd);
1010 1010
 	}
1011 1011
 	// fix permissions
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 {
15 15
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 16
 }
17
-date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
17
+date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings
18 18
 
19 19
 $verbose = 0;
20 20
 $config = array(
21 21
 	'packagename' => 'egroupware-epl',
22
-	'version' => '14.3',        // '14.3'
22
+	'version' => '14.3', // '14.3'
23 23
 	'packaging' => date('Ymd'), // '20160520'
24
-	'branch'  => '14.2',        // checked out branch
25
-	'tag' => '$version.$packaging',	// name of tag
24
+	'branch'  => '14.2', // checked out branch
25
+	'tag' => '$version.$packaging', // name of tag
26 26
 	'checkoutdir' => realpath(__DIR__.'/../..'),
27 27
 	'egw_buildroot' => '/tmp/build_root/epl_14.2_buildroot',
28 28
 	'sourcedir' => '/home/download/stylite-epl/egroupware-epl-14.2',
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	'svnalias' => 'aliases/default-ssh',    // default alias
35 35
 	'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'),
36 36
 	*/
37
-	'extra' => array('stylite', 'esyncpro', 'archive'),	// create an extra archive for given apps
38
-	'aliasdir' => 'egroupware',             // directory created by the alias
39
-	'types' => array('tar.bz2','tar.gz','zip'),
37
+	'extra' => array('stylite', 'esyncpro', 'archive'), // create an extra archive for given apps
38
+	'aliasdir' => 'egroupware', // directory created by the alias
39
+	'types' => array('tar.bz2', 'tar.gz', 'zip'),
40 40
 	// diverse binaries we need
41 41
 	'svn' => trim(`which svn`),
42 42
 	'tar' => trim(`which tar`),
@@ -49,42 +49,42 @@  discard block
 block discarded – undo
49 49
 	'gpg' => trim(`which gpg`),
50 50
 	'editor' => trim(`which vi`),
51 51
 	'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"',
52
-	'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
52
+	'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
53 53
 	'after-checkout' => 'rm -rf */source */templates/*/source pixelegg/content-element-library',
54 54
 	'packager' => '[email protected]',
55 55
 	'obs' => '/home/stylite/obs/stylite-epl',
56
-	'obs_package_alias' => '',	// name used in obs package, if different from packagename
57
-	'changelog' => false,   // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
56
+	'obs_package_alias' => '', // name used in obs package, if different from packagename
57
+	'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
58 58
 	'changelog_packager' => 'Ralf Becker <[email protected]>',
59 59
 	'editchangelog' => '* ',
60 60
 	//'sfuser' => 'ralfbecker',
61 61
 	//'release' => '$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/eGroupware-$version/eGroupware-$version.$packaging/',
62 62
 	'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README',
63 63
 	'skip' => array(),
64
-	'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'),
64
+	'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'),
65 65
 	'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"',
66
-	'github_user' => 'ralfbecker',	// Github user for following token
67
-	'github_token' => '',	// Github repo personal access token from above user
66
+	'github_user' => 'ralfbecker', // Github user for following token
67
+	'github_token' => '', // Github repo personal access token from above user
68 68
 );
69 69
 
70 70
 // process config from command line
71 71
 $argv = $_SERVER['argv'];
72 72
 $prog = array_shift($argv);
73 73
 
74
-while(($arg = array_shift($argv)))
74
+while (($arg = array_shift($argv)))
75 75
 {
76 76
 	if ($arg == '-v' || $arg == '--verbose')
77 77
 	{
78 78
 		++$verbose;
79 79
 	}
80
-	elseif($arg == '-h' || $arg == '--help')
80
+	elseif ($arg == '-h' || $arg == '--help')
81 81
 	{
82 82
 		usage();
83 83
 	}
84
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
84
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
85 85
 	{
86 86
 		$value = array_shift($argv);
87
-		switch($name)
87
+		switch ($name)
88 88
 		{
89 89
 			case 'extra':	// stored as array and allow to add/delete items with +/- prefix
90 90
 			case 'types':
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 			case 'run':
93 93
 				if ($value[0] == '+')
94 94
 				{
95
-					$config[$name] = array_unique(array_merge($config[$name],preg_split('/[ ,]+/',substr($value,1))));
95
+					$config[$name] = array_unique(array_merge($config[$name], preg_split('/[ ,]+/', substr($value, 1))));
96 96
 				}
97 97
 				elseif ($value[0] == '-')
98 98
 				{
99
-					$config[$name] = array_diff($config[$name],preg_split('/[ ,]+/',substr($value,1)));
99
+					$config[$name] = array_diff($config[$name], preg_split('/[ ,]+/', substr($value, 1)));
100 100
 				}
101 101
 				else
102 102
 				{
103
-					$config[$name] = array_unique(preg_split('/[ ,]+/',$value));
103
+					$config[$name] = array_unique(preg_split('/[ ,]+/', $value));
104 104
 				}
105 105
 				break;
106 106
 
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 			case 'release':
110 110
 			case 'copychangelog':
111 111
 				$config[$name] = $value;
112
-				if ($value) array_unshift($config['run'],$name);
112
+				if ($value) array_unshift($config['run'], $name);
113 113
 				break;
114 114
 
115 115
 			case 'editchangelog':
116 116
 				$config[$name] = $value ? $value : true;
117
-				if (!in_array('editchangelog',$config['run']))
117
+				if (!in_array('editchangelog', $config['run']))
118 118
 				{
119
-					array_unshift($config['run'],'editchangelog');
119
+					array_unshift($config['run'], 'editchangelog');
120 120
 				}
121 121
 				break;
122 122
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 				{
126 126
 					usage("Path '$value' not found!");
127 127
 				}
128
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
128
+				if (!in_array('obs', $config['run'])) $config['run'][] = 'obs';
129 129
 				// fall through
130 130
 			default:
131 131
 				$config[$name] = $value;
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 }
145 145
 $svn = $config['svn'];
146 146
 
147
-foreach(array_diff($config['run'],$config['skip']) as $func)
147
+foreach (array_diff($config['run'], $config['skip']) as $func)
148 148
 {
149
-	chdir(dirname(__FILE__));	// make relative filenames work, if other command changes dir
149
+	chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir
150 150
 	call_user_func('do_'.$func);
151 151
 }
152 152
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
162 162
  * @return string with changelog
163 163
  */
164
-function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ')
164
+function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ')
165 165
 {
166 166
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
167 167
 	global $config;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	run_cmd($cmd, $output);
183 183
 
184 184
 	$changelog = '';
185
-	foreach($output as $line)
185
+	foreach ($output as $line)
186 186
 	{
187 187
 		if (substr($line, 0, 4) == "    " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix)))
188 188
 		{
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
 	{
215 215
 		throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!");
216 216
 	}
217
-	if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig')))
217
+	if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig')))
218 218
 	{
219 219
 		throw new Exception("$path not found!");
220 220
 	}
221 221
 	$module = null;
222 222
 	$modules = array();
223
-	foreach(explode("\n", $mrconfig) as $line)
223
+	foreach (explode("\n", $mrconfig) as $line)
224 224
 	{
225 225
 		$matches = null;
226 226
 		if ($line && $line[0] == '[' && preg_match('/^\[([^]]*)\]/', $line, $matches))
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : '').
281 281
 			' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir'];
282 282
 		run_cmd($cmd);
283
-		run_cmd('mr up');	// need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
283
+		run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
284 284
 	}
285 285
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
286 286
 	{
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 	}
305 305
 	chdir($config['checkoutdir']);
306 306
 
307
-	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
307
+	$config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag
308 308
 
309
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
309
+	if (empty($config['tag'])) return; // otherwise we copy everything in svn root!
310 310
 
311 311
 	echo "Creating tag $config[tag]\n";
312 312
 
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
  */
320 320
 function do_release()
321 321
 {
322
-	global $config,$verbose;
322
+	global $config, $verbose;
323 323
 
324 324
 	// push local changes to Github incl. tags
325 325
 	if ($verbose) echo "Pushing changes and tags\n";
326 326
 	chdir($config['checkoutdir']);
327
-	run_cmd($config['mr']. ' up');		// in case someone else pushed something
327
+	run_cmd($config['mr'].' up'); // in case someone else pushed something
328 328
 	chdir($config['checkoutdir']);
329
-	run_cmd($config['git'].' push');	// regular commits like changelog
329
+	run_cmd($config['git'].' push'); // regular commits like changelog
330 330
 	$tag = config_translate('tag');
331
-	run_cmd($config['mr']. ' push origin '.$tag);	// pushing tags in all apps
331
+	run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps
332 332
 
333 333
 	if (empty($config['github_user']) || empty($config['github_token']))
334 334
 	{
@@ -345,26 +345,26 @@  discard block
 block discarded – undo
345 345
 		'body' => $config['changelog'],
346 346
 	);
347 347
 	$response = github_api("/repos/EGroupware/egroupware/releases", $data);
348
-	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']);	// remove {?name,label} template
348
+	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template
349 349
 
350 350
 	$archives = $config['sourcedir'].'/*egroupware-epl-'.$config['version'].'.'.$config['packaging'].'*';
351 351
 
352
-	foreach(glob($archives) as $path)
352
+	foreach (glob($archives) as $path)
353 353
 	{
354 354
 		$label = null;
355 355
 		if (substr($path, -4) == '.zip')
356 356
 		{
357 357
 			$content_type = 'application/zip';
358 358
 		}
359
-		elseif(substr($path, -7) == '.tar.gz')
359
+		elseif (substr($path, -7) == '.tar.gz')
360 360
 		{
361 361
 			$content_type = 'application/x-gzip';
362 362
 		}
363
-		elseif(substr($path, -8) == '.tar.bz2')
363
+		elseif (substr($path, -8) == '.tar.bz2')
364 364
 		{
365 365
 			$content_type = 'application/x-bzip2';
366 366
 		}
367
-		elseif(substr($path, -8) == '.txt.asc')
367
+		elseif (substr($path, -8) == '.txt.asc')
368 368
 		{
369 369
 			$content_type = 'text/plain';
370 370
 			$label = 'Signed hashes of downloads';
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 
383 383
 	if (!empty($config['release']))
384 384
 	{
385
-		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
385
+		$target = config_translate('release'); // allow to use config vars like $svnbranch in module
386 386
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
387 387
 		if ($verbose) echo $cmd."\n";
388 388
 		passthru($cmd);
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
  * @throws Exception
401 401
  * @return array with response
402 402
  */
403
-function github_api($_url, $data, $method='POST', $upload=null, $content_type=null)
403
+function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null)
404 404
 {
405 405
 	global $config, $verbose;
406 406
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	curl_setopt($c, CURLOPT_TIMEOUT, 240);
414 414
 	curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
415 415
 
416
-	switch($method)
416
+	switch ($method)
417 417
 	{
418 418
 		case 'POST':
419 419
 			curl_setopt($c, CURLOPT_POST, true);
@@ -421,13 +421,13 @@  discard block
 block discarded – undo
421 421
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
422 422
 			break;
423 423
 		case 'GET':
424
-			if(count($data)) $url .= '?' . http_build_query($data);
424
+			if (count($data)) $url .= '?'.http_build_query($data);
425 425
 			break;
426 426
 		case 'FILE':
427 427
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
428 428
 			curl_setopt($c, CURLOPT_POST, true);
429 429
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
430
-			if(count($data)) $url .= '?' . http_build_query($data);
430
+			if (count($data)) $url .= '?'.http_build_query($data);
431 431
 			break;
432 432
 		default:
433 433
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	curl_setopt($c, CURLOPT_URL, $url);
436 436
 
437 437
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
438
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
438
+	if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n";
439 439
 
440 440
 	if (($response = curl_exec($c)) === false)
441 441
 	{
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 		curl_setopt($c, CURLOPT_HEADER, true);
444 444
 		curl_setopt($c, CURLOPT_RETURNTRANSFER, false);
445 445
 		curl_exec($c);
446
-		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
446
+		throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : ''));
447 447
 	}
448 448
 
449 449
 	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
  * @param string $name
460 460
  * @param string $value =null value to use, default $config[$name]
461 461
  */
462
-function config_translate($name, $value=null)
462
+function config_translate($name, $value = null)
463 463
 {
464 464
 	global $config;
465 465
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	if (is_string($value) && strpos($value, '$') !== false)
468 468
 	{
469 469
 		$translate = array();
470
-		foreach($config as $n => $val)
470
+		foreach ($config as $n => $val)
471 471
 		{
472 472
 			if (is_string($val)) $translate['$'.$n] = $val;
473 473
 		}
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
  */
494 494
 function do_editchangelog()
495 495
 {
496
-	global $config,$svn;
496
+	global $config, $svn;
497 497
 
498 498
 	echo "Querying changelog from Git/SVN\n";
499 499
 	if (!isset($config['modules']))
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 	// query changelog per repo
504 504
 	$changelog = '';
505 505
 	$last_tag = null;
506
-	foreach($config['modules'] as $branch_url => $modules)
506
+	foreach ($config['modules'] as $branch_url => $modules)
507 507
 	{
508 508
 		$revision = null;
509 509
 		if (substr($branch_url, -4) == '.git')
@@ -516,15 +516,15 @@  discard block
 block discarded – undo
516 516
 			$changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision);
517 517
 		}
518 518
 	}
519
-	$logfile = tempnam('/tmp','checkout-build-archives');
520
-	file_put_contents($logfile,$changelog);
519
+	$logfile = tempnam('/tmp', 'checkout-build-archives');
520
+	file_put_contents($logfile, $changelog);
521 521
 	$cmd = $config['editor'].' '.escapeshellarg($logfile);
522 522
 	passthru($cmd);
523 523
 	$config['changelog'] = file_get_contents($logfile);
524 524
 	// remove trailing newlines
525
-	while (substr($config['changelog'],-1) == "\n")
525
+	while (substr($config['changelog'], -1) == "\n")
526 526
 	{
527
-		$config['changelog'] = substr($config['changelog'],0,-1);
527
+		$config['changelog'] = substr($config['changelog'], 0, -1);
528 528
 	}
529 529
 	// allow user to abort, by deleting the changelog
530 530
 	if (strlen($config['changelog']) <= 2)
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	run_cmd($cmd);
550 550
 
551 551
 	// update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped)
552
-	do_obs(true);	// true: only update debian.changes in obs checkouts
552
+	do_obs(true); // true: only update debian.changes in obs checkouts
553 553
 }
554 554
 
555 555
 /**
@@ -563,41 +563,41 @@  discard block
 block discarded – undo
563 563
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
564 564
  * @return string with changelog
565 565
  */
566
-function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ')
566
+function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ')
567 567
 {
568 568
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
569
-	global $config,$verbose,$svn;
569
+	global $config, $verbose, $svn;
570 570
 
571 571
 	if (is_null($revision))
572 572
 	{
573
-		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
573
+		list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url);
574 574
 		if (empty($branch)) $branch = $config['version'];
575 575
 		$tags_url .= '/tags';
576
-		$pattern='/tags\/(14\.3\.[0-9.]+)/';//str_replace('Stylite-EPL-10\.1',preg_quote($branch),'/tags\/(Stylite-EPL-10\.1\.[0-9.]+)/');
576
+		$pattern = '/tags\/(14\.3\.[0-9.]+)/'; //str_replace('Stylite-EPL-10\.1',preg_quote($branch),'/tags\/(Stylite-EPL-10\.1\.[0-9.]+)/');
577 577
 		$matches = null;
578
-		$revision = get_last_svn_tag($tags_url,$pattern,$matches);
578
+		$revision = get_last_svn_tag($tags_url, $pattern, $matches);
579 579
 		$tag = $matches[1];
580 580
 	}
581
-	elseif(!is_numeric($revision))
581
+	elseif (!is_numeric($revision))
582 582
 	{
583
-		$revision = get_last_svn_tag($tags_url,$tag=$revision);
583
+		$revision = get_last_svn_tag($tags_url, $tag = $revision);
584 584
 	}
585 585
 	$cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url);
586 586
 	if (($v = $verbose))
587 587
 	{
588 588
 		echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n";
589
-		$verbose = false;	// otherwise no $output!
589
+		$verbose = false; // otherwise no $output!
590 590
 	}
591 591
 	$output = array();
592
-	run_cmd($cmd,$output);
592
+	run_cmd($cmd, $output);
593 593
 	$verbose = $v;
594
-	array_shift($output);	// remove the command
594
+	array_shift($output); // remove the command
595 595
 
596
-	$xml = simplexml_load_string($output=implode("\n",$output));
596
+	$xml = simplexml_load_string($output = implode("\n", $output));
597 597
 	$message = '';
598
-	foreach($xml as $log)
598
+	foreach ($xml as $log)
599 599
 	{
600
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
600
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore
601 601
 
602 602
 		$message .= $msg."\n";
603 603
 	}
@@ -614,25 +614,25 @@  discard block
 block discarded – undo
614 614
  * @param string $prefix ='* '
615 615
  * @return string
616 616
  */
617
-function _match_log_pattern($msg, $log_pattern, $prefix='* ')
617
+function _match_log_pattern($msg, $log_pattern, $prefix = '* ')
618 618
 {
619 619
 	$pattern_len = strlen($log_pattern);
620 620
 	$prefix_len = strlen($prefix);
621 621
 
622 622
 	$matches = null;
623
-	if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches))
623
+	if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches))
624 624
 	{
625 625
 		$msg = $matches[1];
626 626
 	}
627
-	elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern)
627
+	elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern)
628 628
 	{
629
-		list($msg) = explode("\n",$msg);
629
+		list($msg) = explode("\n", $msg);
630 630
 	}
631
-	elseif($log_pattern)
631
+	elseif ($log_pattern)
632 632
 	{
633 633
 		return null;
634 634
 	}
635
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
635
+	if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg;
636 636
 
637 637
 	return $msg;
638 638
 }
@@ -646,29 +646,29 @@  discard block
 block discarded – undo
646 646
  * @param array &$matches=null on return matches of preg_match
647 647
  * @return int revision of last svn tag matching pattern
648 648
  */
649
-function get_last_svn_tag($tags_url,$pattern,&$matches=null)
649
+function get_last_svn_tag($tags_url, $pattern, &$matches = null)
650 650
 {
651
-	global $verbose,$svn;
651
+	global $verbose, $svn;
652 652
 
653 653
 	$cmd = $svn.' log --xml --limit 40 '.escapeshellarg($tags_url);
654 654
 	if (($v = $verbose))
655 655
 	{
656 656
 		echo "Querying SVN for last tags\n$cmd\n";
657
-		$verbose = false;	// otherwise no $output!
657
+		$verbose = false; // otherwise no $output!
658 658
 	}
659 659
 	$output = array();
660
-	run_cmd($cmd,$output);
660
+	run_cmd($cmd, $output);
661 661
 	$verbose = $v;
662
-	array_shift($output);	// remove the command
662
+	array_shift($output); // remove the command
663 663
 
664
-	$xml = simplexml_load_string($output=implode("\n",$output));
665
-	foreach($xml as $log)
664
+	$xml = simplexml_load_string($output = implode("\n", $output));
665
+	foreach ($xml as $log)
666 666
 	{
667 667
 		//print_r($log);
668
-		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
669
-			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
668
+		if ($pattern[0] != '/' && strpos($log->msg, $pattern) !== false ||
669
+			$pattern[0] == '/' && preg_match($pattern, $log->msg, $matches))
670 670
 		{
671
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
671
+			if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n";
672 672
 			return (int)$log['revision'];
673 673
 		}
674 674
 	}
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
  *
681 681
  * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it
682 682
  */
683
-function do_obs($only_update_changelog=false)
683
+function do_obs($only_update_changelog = false)
684 684
 {
685
-	global $config,$verbose;
685
+	global $config, $verbose;
686 686
 
687 687
 	if (!is_dir($config['obs']))
688 688
 	{
@@ -692,25 +692,25 @@  discard block
 block discarded – undo
692 692
 	run_cmd('osc up '.$config['obs']);
693 693
 
694 694
 	$n = 0;
695
-	foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
695
+	foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
696 696
 	{
697 697
 		if (basename(dirname($path)) == '.osc' ||
698 698
 			!preg_match('/\/('.preg_quote($config['packagename']).
699 699
 				($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : '').
700
-				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/',$path))
700
+				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/', $path))
701 701
 		{
702 702
 			continue;
703 703
 		}
704 704
 		$matches = null;
705
-		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) &&
706
-			file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
705
+		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) &&
706
+			file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
707 707
 		{
708 708
 			if (basename($path) != basename($new_name))
709 709
 			{
710 710
 				unlink($path);
711 711
 				if ($verbose) echo "rm $path\n";
712 712
 			}
713
-			copy($new_name,dirname($path).'/'.basename($new_name));
713
+			copy($new_name, dirname($path).'/'.basename($new_name));
714 714
 			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
715 715
 			++$n;
716 716
 		}
@@ -720,35 +720,35 @@  discard block
 block discarded – undo
720 720
 			$config['changelog'] = parse_current_changelog();
721 721
 		}
722 722
 		// updating dsc, spec and changelog files
723
-		if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') ||
723
+		if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') ||
724 724
 			!empty($config['changelog']) && basename($path) == 'debian.changes')
725 725
 		{
726 726
 			$content = $content_was = file_get_contents($path);
727 727
 
728
-			if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec')
728
+			if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec')
729 729
 			{
730
-				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content);
730
+				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content);
731 731
 			}
732
-			if (substr($path,-4) == '.dsc')
732
+			if (substr($path, -4) == '.dsc')
733 733
 			{
734 734
 				$content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'.
735 735
 					preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m',
736
-					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content);
736
+					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content);
737 737
 			}
738
-			if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false)
738
+			if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false)
739 739
 			{
740 740
 				$content = update_changelog($content);
741 741
 			}
742
-			if (!empty($config['changelog']) && substr($path,-5) == '.spec' &&
743
-				($pos_changelog = strpos($content,'%changelog')) !== false)
742
+			if (!empty($config['changelog']) && substr($path, -5) == '.spec' &&
743
+				($pos_changelog = strpos($content, '%changelog')) !== false)
744 744
 			{
745 745
 				$pos_changelog += strlen("%changelog\n");
746
-				$content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
747
-					$config['changelog']."\n".substr($content,$pos_changelog);
746
+				$content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
747
+					$config['changelog']."\n".substr($content, $pos_changelog);
748 748
 			}
749 749
 			if ($content != $content_was)
750 750
 			{
751
-				file_put_contents($path,$content);
751
+				file_put_contents($path, $content);
752 752
 				if ($verbose) echo "Updated $path\n";
753 753
 				++$n;
754 754
 			}
@@ -774,21 +774,21 @@  discard block
 block discarded – undo
774 774
 
775 775
 	$changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes');
776 776
 	$lines = explode("\n", $changelog, 100);
777
-	foreach($lines as $n => $line)
777
+	foreach ($lines as $n => $line)
778 778
 	{
779
-		if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version'].'.'.$config['packaging']).'/', $line))
779
+		if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version'].'.'.$config['packaging']).'/', $line))
780 780
 		{
781
-			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
781
+			$n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header
782 782
 			$logentry = '';
783
-			while($lines[$n])	// entry is terminated by empty line
783
+			while ($lines[$n])	// entry is terminated by empty line
784 784
 			{
785 785
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
786 786
 				++$n;
787 787
 			}
788
-			return substr($logentry, 0, -1);	// remove training "\n"
788
+			return substr($logentry, 0, -1); // remove training "\n"
789 789
 		}
790 790
 	}
791
-	return null;	// paragraph for current version NOT found
791
+	return null; // paragraph for current version NOT found
792 792
 }
793 793
 
794 794
 /**
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 	global $config;
803 803
 
804 804
 	list($header) = explode("\n", $content);
805
-	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
806
-	if (substr($config['changelog'],0,2) != '  ') $config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
805
+	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/', '('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
806
+	if (substr($config['changelog'], 0, 2) != '  ') $config['changelog'] = '  '.implode("\n  ", explode("\n", $config['changelog']));
807 807
 	$content = $new_header."\n\n".$config['changelog'].
808 808
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
809 809
 
@@ -817,9 +817,9 @@  discard block
 block discarded – undo
817 817
 {
818 818
 	global $config;
819 819
 
820
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
820
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
821 821
 	{
822
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
822
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
823 823
 	}
824 824
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
825 825
 
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
839 839
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
840 840
 	run_cmd($cmd);
841
-	unlink($sumsfile);	// delete the unsigned file
841
+	unlink($sumsfile); // delete the unsigned file
842 842
 }
843 843
 
844 844
 /**
@@ -848,31 +848,31 @@  discard block
 block discarded – undo
848 848
 {
849 849
 	global $config;
850 850
 
851
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
852
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
851
+	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true);
852
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
853 853
 	{
854
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
854
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
855 855
 	}
856 856
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
857 857
 	$sums = '';
858 858
 
859 859
 	chdir($config['egw_buildroot']);
860 860
 
861
-	if($config['extra'])
861
+	if ($config['extra'])
862 862
 	{
863
-		foreach($config['extra'] as $key => $module)
863
+		foreach ($config['extra'] as $key => $module)
864 864
 		{
865
-			if (strpos($module,'/') !== false) $config['extra'][$key] = basename($module);
865
+			if (strpos($module, '/') !== false) $config['extra'][$key] = basename($module);
866 866
 		}
867
-		$exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/',$config['extra']);
867
+		$exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $config['extra']);
868 868
 	}
869
-	foreach($config['types'] as $type)
869
+	foreach ($config['types'] as $type)
870 870
 	{
871 871
 		echo "Creating $type archives\n";
872 872
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
873 873
 
874 874
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
875
-		switch($type)
875
+		switch ($type)
876 876
 		{
877 877
 			case 'tar.bz2':
878 878
 			case 'tar.gz':
@@ -880,18 +880,18 @@  discard block
 block discarded – undo
880 880
 				break;
881 881
 			case 'zip':
882 882
 				$cmd = file_exists($file) ? $config['rm'].' -f '.$file.'; ' : '';
883
-				$cmd .= $config['mv'].' egroupware/'.implode(' egroupware/',$config['extra']).' . ;';
883
+				$cmd .= $config['mv'].' egroupware/'.implode(' egroupware/', $config['extra']).' . ;';
884 884
 				$cmd .= $config['zip'].' -q -r -9 '.$file.' egroupware ;';
885
-				$cmd .= $config['mv'].' '.implode(' ',$config['extra']).' egroupware';
885
+				$cmd .= $config['mv'].' '.implode(' ', $config['extra']).' egroupware';
886 886
 				break;
887 887
 		}
888 888
 		run_cmd($cmd);
889 889
 		$sums .= sha1_file($file)."\t".basename($file)."\n";
890 890
 
891
-		foreach($config['extra'] as $module)
891
+		foreach ($config['extra'] as $module)
892 892
 		{
893 893
 			$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$module.'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
894
-			switch($type)
894
+			switch ($type)
895 895
 			{
896 896
 				case 'tar.bz2':
897 897
 				case 'tar.gz':
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 		}
908 908
 	}
909 909
 	// writing sha1sum file
910
-	file_put_contents($sumsfile,$sums);
910
+	file_put_contents($sumsfile, $sums);
911 911
 }
912 912
 
913 913
 /**
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
  */
916 916
 function do_virusscan()
917 917
 {
918
-	global $config,$verbose;
918
+	global $config, $verbose;
919 919
 
920 920
 	if (!file_exists($config['clamscan']) || !is_executable($config['clamscan']))
921 921
 	{
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
930 930
 		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
931 931
 		$output = null;
932
-		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
932
+		run_cmd($cmd, $output, 1); // 1 = ignore already up to date database
933 933
 	}
934 934
 	echo "Starting virusscan\n";
935 935
 	$cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot'];
@@ -987,12 +987,12 @@  discard block
 block discarded – undo
987 987
  */
988 988
 function do_svncheckout()
989 989
 {
990
-	global $config,$svn;
990
+	global $config, $svn;
991 991
 
992 992
 	echo "Starting svn checkout/update\n";
993 993
 	if (!file_exists($config['checkoutdir']))
994 994
 	{
995
-		mkdir($config['checkoutdir'],0755,true);
995
+		mkdir($config['checkoutdir'], 0755, true);
996 996
 	}
997 997
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
998 998
 	{
@@ -1007,17 +1007,17 @@  discard block
 block discarded – undo
1007 1007
 		{
1008 1008
 			get_modules_per_repo();
1009 1009
 		}
1010
-		$config['svntag'] = config_translate('svntag');	// in case svntag command did not run, translate tag name
1010
+		$config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name
1011 1011
 
1012 1012
 		if (file_exists($config['aliasdir']))
1013 1013
 		{
1014
-			system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout, as we dont implement switching tags
1014
+			system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags
1015 1015
 			clearstatcache();
1016 1016
 		}
1017
-		foreach($config['modules'] as $repo => $modules)
1017
+		foreach ($config['modules'] as $repo => $modules)
1018 1018
 		{
1019 1019
 			$cmd = $svn.' co ';
1020
-			foreach($modules as $path => $url)
1020
+			foreach ($modules as $path => $url)
1021 1021
 			{
1022 1022
 				if ($path == $config['aliasdir'])
1023 1023
 				{
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 					$cmd = $svn.' co ';
1028 1028
 					continue;
1029 1029
 				}
1030
-				if(file_exists($config['aliasdir']))
1030
+				if (file_exists($config['aliasdir']))
1031 1031
 				{
1032 1032
 					die("'egroupware' applications must be first one in externals!\n");
1033 1033
 				}
@@ -1045,16 +1045,16 @@  discard block
 block discarded – undo
1045 1045
 			// check if correct branch
1046 1046
 			$cmd = 'LANG=C '.$svn.' info';
1047 1047
 			$output = $ret = null;
1048
-			exec($cmd,$output,$ret);
1049
-			foreach($output as $line)
1048
+			exec($cmd, $output, $ret);
1049
+			foreach ($output as $line)
1050 1050
 			{
1051
-				if ($ret || substr($line,0,5) == 'URL: ')
1051
+				if ($ret || substr($line, 0, 5) == 'URL: ')
1052 1052
 				{
1053
-					$url = substr($line,5);
1054
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1053
+					$url = substr($line, 5);
1054
+					if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1055 1055
 					{
1056 1056
 						echo "Checkout is of wrong branch --> deleting it\n";
1057
-						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1057
+						system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout
1058 1058
 						clearstatcache();
1059 1059
 					}
1060 1060
 					break;
@@ -1066,10 +1066,10 @@  discard block
 block discarded – undo
1066 1066
 		run_cmd($cmd);
1067 1067
 
1068 1068
 		chdir($config['aliasdir']);
1069
-		foreach($config['extra'] as $module)
1069
+		foreach ($config['extra'] as $module)
1070 1070
 		{
1071
-			$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1072
-			$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1071
+			$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1072
+			$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1073 1073
 			$url .= $module;
1074 1074
 			$cmd = $svn.' co '.$url;
1075 1075
 			run_cmd($cmd);
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
  */
1095 1095
 function get_modules_per_svn_repo()
1096 1096
 {
1097
-	global $config,$svn,$verbose;
1097
+	global $config, $svn, $verbose;
1098 1098
 
1099 1099
 	// process alias/externals
1100 1100
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
@@ -1102,27 +1102,27 @@  discard block
 block discarded – undo
1102 1102
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1103 1103
 	if ($verbose) echo $cmd."\n";
1104 1104
 	$output = $ret = null;
1105
-	exec($cmd,$output,$ret);
1105
+	exec($cmd, $output, $ret);
1106 1106
 	$config['modules'] = array();
1107
-	foreach($output as $line)
1107
+	foreach ($output as $line)
1108 1108
 	{
1109 1109
 		$line = trim($line);
1110 1110
 		if (empty($line) || $line[0] == '#') continue;
1111
-		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1111
+		list($path, $url) = preg_split('/[ \t\r\n]+/', $line);
1112 1112
 		$matches = null;
1113
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1113
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1114 1114
 		$repo = $matches[1];
1115 1115
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1116 1116
 		$config['modules'][$repo][$path] = $url;
1117 1117
 	}
1118 1118
 	// process extra modules
1119
-	foreach($config['extra'] as $module)
1119
+	foreach ($config['extra'] as $module)
1120 1120
 	{
1121
-		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1122
-		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1121
+		$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1122
+		$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1123 1123
 		$url .= $module;
1124
-		if (strpos($module,'://') !== false) $module = basename($module);
1125
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1124
+		if (strpos($module, '://') !== false) $module = basename($module);
1125
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1126 1126
 		$repo = $matches[1];
1127 1127
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1128 1128
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
@@ -1136,11 +1136,11 @@  discard block
 block discarded – undo
1136 1136
  */
1137 1137
 function do_svntag()
1138 1138
 {
1139
-	global $config,$svn;
1139
+	global $config, $svn;
1140 1140
 
1141
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1141
+	if (empty($config['svntag'])) return; // otherwise we copy everything in svn root!
1142 1142
 
1143
-	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1143
+	$config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag
1144 1144
 
1145 1145
 	echo "Creating SVN tag $config[svntag]\n";
1146 1146
 	if (!isset($config['modules']))
@@ -1148,9 +1148,9 @@  discard block
 block discarded – undo
1148 1148
 		get_modules_per_repo();
1149 1149
 	}
1150 1150
 	// create tags (per repo)
1151
-	foreach($config['modules'] as $repo => $modules)
1151
+	foreach ($config['modules'] as $repo => $modules)
1152 1152
 	{
1153
-		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/';
1153
+		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/';
1154 1154
 		run_cmd($cmd);
1155 1155
 	}
1156 1156
 }
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1164 1164
  * @return int exit code of $cmd
1165 1165
  */
1166
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
1166
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
1167 1167
 {
1168 1168
 	global $verbose;
1169 1169
 
@@ -1171,18 +1171,18 @@  discard block
 block discarded – undo
1171 1171
 	{
1172 1172
 		echo $cmd."\n";
1173 1173
 		$ret = null;
1174
-		system($cmd,$ret);
1174
+		system($cmd, $ret);
1175 1175
 	}
1176 1176
 	else
1177 1177
 	{
1178 1178
 		$output[] = $cmd;
1179
-		exec($cmd,$output,$ret);
1180
-		if ($verbose) echo implode("\n",$output)."\n";
1179
+		exec($cmd, $output, $ret);
1180
+		if ($verbose) echo implode("\n", $output)."\n";
1181 1181
 	}
1182
-	if ($ret && !in_array($ret,(array)$no_bailout))
1182
+	if ($ret && !in_array($ret, (array)$no_bailout))
1183 1183
 	{
1184
-		if (!$verbose) echo implode("\n",$output)."\n";
1185
-		throw new Exception("Error during '$cmd' --> aborting",$ret);
1184
+		if (!$verbose) echo implode("\n", $output)."\n";
1185
+		throw new Exception("Error during '$cmd' --> aborting", $ret);
1186 1186
 	}
1187 1187
 	return $ret;
1188 1188
 }
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 			return 'NULL';
1210 1210
 		case 'object':
1211 1211
 		case 'array':
1212
-			return str_replace(array("\n",'    '/*,'Array'*/),'',print_r($var,true));
1212
+			return str_replace(array("\n", '    '/*,'Array'*/), '', print_r($var, true));
1213 1213
 	}
1214 1214
 	return 'UNKNOWN TYPE!';
1215 1215
 }
@@ -1219,17 +1219,17 @@  discard block
 block discarded – undo
1219 1219
  *
1220 1220
  * @param string $error =null optional error-message
1221 1221
  */
1222
-function usage($error=null)
1222
+function usage($error = null)
1223 1223
 {
1224
-	global $prog,$config;
1224
+	global $prog, $config;
1225 1225
 
1226 1226
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n";
1227 1227
 	echo "options and their defaults:\n";
1228
-	unset($config['modules']);	// they give an error, because of nested array and are quite lengthy
1229
-	foreach($config as $name => $default)
1228
+	unset($config['modules']); // they give an error, because of nested array and are quite lengthy
1229
+	foreach ($config as $name => $default)
1230 1230
 	{
1231
-		if (is_array($default)) $default = implode(' ',$default);
1232
-		echo '--'.str_pad($name,20).$default."\n";
1231
+		if (is_array($default)) $default = implode(' ', $default);
1232
+		echo '--'.str_pad($name, 20).$default."\n";
1233 1233
 	}
1234 1234
 	if ($error)
1235 1235
 	{
Please login to merge, or discard this patch.
Braces   +211 added lines, -52 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@  discard block
 block discarded – undo
10 10
  * @version $Id$
11 11
  */
12 12
 
13
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
13
+if (php_sapi_name() !== 'cli')
14
+{
15
+	// security precaution: forbit calling setup-cli as web-page
14 16
 {
15 17
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 18
 }
19
+}
17 20
 date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
18 21
 
19 22
 $verbose = 0;
@@ -109,7 +112,10 @@  discard block
 block discarded – undo
109 112
 			case 'release':
110 113
 			case 'copychangelog':
111 114
 				$config[$name] = $value;
112
-				if ($value) array_unshift($config['run'],$name);
115
+				if ($value)
116
+				{
117
+					array_unshift($config['run'],$name);
118
+				}
113 119
 				break;
114 120
 
115 121
 			case 'editchangelog':
@@ -125,7 +131,10 @@  discard block
 block discarded – undo
125 131
 				{
126 132
 					usage("Path '$value' not found!");
127 133
 				}
128
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
134
+				if (!in_array('obs',$config['run']))
135
+				{
136
+					$config['run'][] = 'obs';
137
+				}
129 138
 				// fall through
130 139
 			default:
131 140
 				$config[$name] = $value;
@@ -177,7 +186,10 @@  discard block
 block discarded – undo
177 186
 	}
178 187
 
179 188
 	$cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD');
180
-	if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd;
189
+	if (getcwd() != $path)
190
+	{
191
+		$cmd = 'cd '.$path.'; '.$cmd;
192
+	}
181 193
 	$output = null;
182 194
 	run_cmd($cmd, $output);
183 195
 
@@ -208,7 +220,10 @@  discard block
 block discarded – undo
208 220
 {
209 221
 	global $config, $verbose;
210 222
 
211
-	if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n";
223
+	if ($verbose)
224
+	{
225
+		echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n";
226
+	}
212 227
 
213 228
 	if (!is_dir($config['checkoutdir']))
214 229
 	{
@@ -235,11 +250,17 @@  discard block
 block discarded – undo
235 250
 		elseif (isset($module) && preg_match('/^checkout\s*=\s*(git clone (-b [0-9.]+)? (git[^ ]+)|svn checkout ((svn|http)[^ ]+))/', $line, $matches))
236 251
 		{
237 252
 			$repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[4] : $matches[3];
238
-			if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo);
253
+			if (substr($matches[1], 0, 3) == 'svn')
254
+			{
255
+				$repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo);
256
+			}
239 257
 			$modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url;
240 258
 		}
241 259
 	}
242
-	if ($verbose) print_r($modules);
260
+	if ($verbose)
261
+	{
262
+		print_r($modules);
263
+	}
243 264
 	return $modules;
244 265
 }
245 266
 
@@ -306,7 +327,11 @@  discard block
 block discarded – undo
306 327
 
307 328
 	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
308 329
 
309
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
330
+	if (empty($config['tag']))
331
+	{
332
+		return;
333
+	}
334
+	// otherwise we copy everything in svn root!
310 335
 
311 336
 	echo "Creating tag $config[tag]\n";
312 337
 
@@ -322,7 +347,10 @@  discard block
 block discarded – undo
322 347
 	global $config,$verbose;
323 348
 
324 349
 	// push local changes to Github incl. tags
325
-	if ($verbose) echo "Pushing changes and tags\n";
350
+	if ($verbose)
351
+	{
352
+		echo "Pushing changes and tags\n";
353
+	}
326 354
 	chdir($config['checkoutdir']);
327 355
 	run_cmd($config['mr']. ' up');		// in case someone else pushed something
328 356
 	chdir($config['checkoutdir']);
@@ -384,7 +412,10 @@  discard block
 block discarded – undo
384 412
 	{
385 413
 		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
386 414
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
387
-		if ($verbose) echo $cmd."\n";
415
+		if ($verbose)
416
+		{
417
+			echo $cmd."\n";
418
+		}
388 419
 		passthru($cmd);
389 420
 	}
390 421
 }
@@ -417,25 +448,40 @@  discard block
 block discarded – undo
417 448
 	{
418 449
 		case 'POST':
419 450
 			curl_setopt($c, CURLOPT_POST, true);
420
-			if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT);
451
+			if (is_array($data))
452
+			{
453
+				$data = json_encode($data, JSON_FORCE_OBJECT);
454
+			}
421 455
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
422 456
 			break;
423 457
 		case 'GET':
424
-			if(count($data)) $url .= '?' . http_build_query($data);
458
+			if(count($data))
459
+			{
460
+				$url .= '?' . http_build_query($data);
461
+			}
425 462
 			break;
426 463
 		case 'FILE':
427 464
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
428 465
 			curl_setopt($c, CURLOPT_POST, true);
429 466
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
430
-			if(count($data)) $url .= '?' . http_build_query($data);
467
+			if(count($data))
468
+			{
469
+				$url .= '?' . http_build_query($data);
470
+			}
431 471
 			break;
432 472
 		default:
433 473
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
434 474
 	}
435 475
 	curl_setopt($c, CURLOPT_URL, $url);
436 476
 
437
-	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
438
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
477
+	if (is_string($data))
478
+	{
479
+		$short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
480
+	}
481
+	if ($verbose)
482
+	{
483
+		echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
484
+	}
439 485
 
440 486
 	if (($response = curl_exec($c)) === false)
441 487
 	{
@@ -446,7 +492,10 @@  discard block
 block discarded – undo
446 492
 		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
447 493
 	}
448 494
 
449
-	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
495
+	if ($verbose)
496
+	{
497
+		echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
498
+	}
450 499
 
451 500
 	curl_close($c);
452 501
 
@@ -463,13 +512,19 @@  discard block
 block discarded – undo
463 512
 {
464 513
 	global $config;
465 514
 
466
-	if (!isset($value)) $value = $config[$name];
515
+	if (!isset($value))
516
+	{
517
+		$value = $config[$name];
518
+	}
467 519
 	if (is_string($value) && strpos($value, '$') !== false)
468 520
 	{
469 521
 		$translate = array();
470 522
 		foreach($config as $n => $val)
471 523
 		{
472
-			if (is_string($val)) $translate['$'.$n] = $val;
524
+			if (is_string($val))
525
+			{
526
+				$translate['$'.$n] = $val;
527
+			}
473 528
 		}
474 529
 		$value = strtr($value, $translate);
475 530
 	}
@@ -571,7 +626,10 @@  discard block
 block discarded – undo
571 626
 	if (is_null($revision))
572 627
 	{
573 628
 		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
574
-		if (empty($branch)) $branch = $config['version'];
629
+		if (empty($branch))
630
+		{
631
+			$branch = $config['version'];
632
+		}
575 633
 		$tags_url .= '/tags';
576 634
 		$pattern='/tags\/(14\.3\.[0-9.]+)/';//str_replace('Stylite-EPL-10\.1',preg_quote($branch),'/tags\/(Stylite-EPL-10\.1\.[0-9.]+)/');
577 635
 		$matches = null;
@@ -597,11 +655,18 @@  discard block
 block discarded – undo
597 655
 	$message = '';
598 656
 	foreach($xml as $log)
599 657
 	{
600
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
658
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix)))
659
+		{
660
+			continue;
661
+		}
662
+		// no match --> ignore
601 663
 
602 664
 		$message .= $msg."\n";
603 665
 	}
604
-	if ($verbose) echo $message;
666
+	if ($verbose)
667
+	{
668
+		echo $message;
669
+	}
605 670
 
606 671
 	return $message;
607 672
 }
@@ -632,7 +697,10 @@  discard block
 block discarded – undo
632 697
 	{
633 698
 		return null;
634 699
 	}
635
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
700
+	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix)
701
+	{
702
+		$msg = $prefix.$msg;
703
+	}
636 704
 
637 705
 	return $msg;
638 706
 }
@@ -668,7 +736,10 @@  discard block
 block discarded – undo
668 736
 		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
669 737
 			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
670 738
 		{
671
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
739
+			if ($verbose)
740
+			{
741
+				echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
742
+			}
672 743
 			return (int)$log['revision'];
673 744
 		}
674 745
 	}
@@ -688,7 +759,10 @@  discard block
 block discarded – undo
688 759
 	{
689 760
 		usage("Path '$config[obs]' not found!");
690 761
 	}
691
-	if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n";
762
+	if ($verbose)
763
+	{
764
+		echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n";
765
+	}
692 766
 	run_cmd('osc up '.$config['obs']);
693 767
 
694 768
 	$n = 0;
@@ -708,10 +782,16 @@  discard block
 block discarded – undo
708 782
 			if (basename($path) != basename($new_name))
709 783
 			{
710 784
 				unlink($path);
711
-				if ($verbose) echo "rm $path\n";
785
+				if ($verbose)
786
+				{
787
+					echo "rm $path\n";
788
+				}
712 789
 			}
713 790
 			copy($new_name,dirname($path).'/'.basename($new_name));
714
-			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
791
+			if ($verbose)
792
+			{
793
+				echo "cp $new_name ".dirname($path)."/\n";
794
+			}
715 795
 			++$n;
716 796
 		}
717 797
 		// if we have no changelog (eg. because commands run separate), try parsing it from changelog file
@@ -749,7 +829,10 @@  discard block
 block discarded – undo
749 829
 			if ($content != $content_was)
750 830
 			{
751 831
 				file_put_contents($path,$content);
752
-				if ($verbose) echo "Updated $path\n";
832
+				if ($verbose)
833
+				{
834
+					echo "Updated $path\n";
835
+				}
753 836
 				++$n;
754 837
 			}
755 838
 		}
@@ -780,9 +863,12 @@  discard block
 block discarded – undo
780 863
 		{
781 864
 			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
782 865
 			$logentry = '';
783
-			while($lines[$n])	// entry is terminated by empty line
866
+			while($lines[$n])
867
+			{
868
+				// entry is terminated by empty line
784 869
 			{
785 870
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
871
+			}
786 872
 				++$n;
787 873
 			}
788 874
 			return substr($logentry, 0, -1);	// remove training "\n"
@@ -803,7 +889,10 @@  discard block
 block discarded – undo
803 889
 
804 890
 	list($header) = explode("\n", $content);
805 891
 	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
806
-	if (substr($config['changelog'],0,2) != '  ') $config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
892
+	if (substr($config['changelog'],0,2) != '  ')
893
+	{
894
+		$config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
895
+	}
807 896
 	$content = $new_header."\n\n".$config['changelog'].
808 897
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
809 898
 
@@ -817,10 +906,13 @@  discard block
 block discarded – undo
817 906
 {
818 907
 	global $config;
819 908
 
820
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
909
+	if (substr($config['sourcedir'],0,2) == '~/')
910
+	{
911
+		// sha1_file cant deal with '~/rpm'
821 912
 	{
822 913
 		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
823 914
 	}
915
+	}
824 916
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
825 917
 
826 918
 	if (!file_exists($sumsfile))
@@ -831,11 +923,17 @@  discard block
 block discarded – undo
831 923
 	// signing it
832 924
 	if (empty($config['gpg']) || !file_exists($config['gpg']))
833 925
 	{
834
-		if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n";
926
+		if (!empty($config['gpg']))
927
+		{
928
+			echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n";
929
+		}
835 930
 		return;
836 931
 	}
837 932
 	echo "Signing sha1sum file:\n";
838
-	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
933
+	if (file_exists($sumsfile.'.asc'))
934
+	{
935
+		unlink($sumsfile.'.asc');
936
+	}
839 937
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
840 938
 	run_cmd($cmd);
841 939
 	unlink($sumsfile);	// delete the unsigned file
@@ -848,11 +946,17 @@  discard block
 block discarded – undo
848 946
 {
849 947
 	global $config;
850 948
 
851
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
852
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
949
+	if (!file_exists($config['sourcedir']))
950
+	{
951
+		mkdir($config['sourcedir'],0755,true);
952
+	}
953
+	if (substr($config['sourcedir'],0,2) == '~/')
954
+	{
955
+		// sha1_file cant deal with '~/rpm'
853 956
 	{
854 957
 		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
855 958
 	}
959
+	}
856 960
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
857 961
 	$sums = '';
858 962
 
@@ -862,7 +966,10 @@  discard block
 block discarded – undo
862 966
 	{
863 967
 		foreach($config['extra'] as $key => $module)
864 968
 		{
865
-			if (strpos($module,'/') !== false) $config['extra'][$key] = basename($module);
969
+			if (strpos($module,'/') !== false)
970
+			{
971
+				$config['extra'][$key] = basename($module);
972
+			}
866 973
 		}
867 974
 		$exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/',$config['extra']);
868 975
 	}
@@ -927,7 +1034,10 @@  discard block
 block discarded – undo
927 1034
 	{
928 1035
 		echo "Updating virus signatures\n";
929 1036
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
930
-		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
1037
+		if (!$verbose && function_exists('posix_getuid') && posix_getuid())
1038
+		{
1039
+			echo $cmd."\n";
1040
+		}
931 1041
 		$output = null;
932 1042
 		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
933 1043
 	}
@@ -955,7 +1065,10 @@  discard block
 block discarded – undo
955 1065
 	}
956 1066
 
957 1067
 	// we need to stash uncommited changes like .mrconfig, before copying
958
-	if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash");
1068
+	if (file_exists($config['checkoutdir'].'/.git'))
1069
+	{
1070
+		run_cmd("cd $config[checkoutdir]; git stash");
1071
+	}
959 1072
 
960 1073
 	try {
961 1074
 		$cmd = '/usr/bin/rsync -r --delete --exclude .svn --exclude .git '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/';
@@ -965,8 +1078,14 @@  discard block
 block discarded – undo
965 1078
 	catch (Exception $e) {
966 1079
 		// catch failures to pop stash, before throwing exception
967 1080
 	}
968
-	if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop");
969
-	if (isset($e)) throw $e;
1081
+	if (file_exists($config['checkoutdir'].'/.git'))
1082
+	{
1083
+		run_cmd("git stash pop");
1084
+	}
1085
+	if (isset($e))
1086
+	{
1087
+		throw $e;
1088
+	}
970 1089
 
971 1090
 	if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#')
972 1091
 	{
@@ -1051,9 +1170,12 @@  discard block
 block discarded – undo
1051 1170
 				if ($ret || substr($line,0,5) == 'URL: ')
1052 1171
 				{
1053 1172
 					$url = substr($line,5);
1054
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1173
+					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)
1174
+					{
1175
+						// wrong branch (or no svn dir)
1055 1176
 					{
1056 1177
 						echo "Checkout is of wrong branch --> deleting it\n";
1178
+					}
1057 1179
 						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1058 1180
 						clearstatcache();
1059 1181
 					}
@@ -1100,19 +1222,31 @@  discard block
 block discarded – undo
1100 1222
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
1101 1223
 	$url = $svnbranch.'/'.$config['svnalias'];
1102 1224
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1103
-	if ($verbose) echo $cmd."\n";
1225
+	if ($verbose)
1226
+	{
1227
+		echo $cmd."\n";
1228
+	}
1104 1229
 	$output = $ret = null;
1105 1230
 	exec($cmd,$output,$ret);
1106 1231
 	$config['modules'] = array();
1107 1232
 	foreach($output as $line)
1108 1233
 	{
1109 1234
 		$line = trim($line);
1110
-		if (empty($line) || $line[0] == '#') continue;
1235
+		if (empty($line) || $line[0] == '#')
1236
+		{
1237
+			continue;
1238
+		}
1111 1239
 		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1112 1240
 		$matches = null;
1113
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1241
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches))
1242
+		{
1243
+			die("Invalid SVN URL: $url\n");
1244
+		}
1114 1245
 		$repo = $matches[1];
1115
-		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1246
+		if ($repo == 'http://svn.egroupware.org/egroupware')
1247
+		{
1248
+			$repo = 'svn+ssh://[email protected]/egroupware';
1249
+		}
1116 1250
 		$config['modules'][$repo][$path] = $url;
1117 1251
 	}
1118 1252
 	// process extra modules
@@ -1121,13 +1255,25 @@  discard block
 block discarded – undo
1121 1255
 		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1122 1256
 		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1123 1257
 		$url .= $module;
1124
-		if (strpos($module,'://') !== false) $module = basename($module);
1125
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1258
+		if (strpos($module,'://') !== false)
1259
+		{
1260
+			$module = basename($module);
1261
+		}
1262
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches))
1263
+		{
1264
+			die("Invalid SVN URL: $url\n");
1265
+		}
1126 1266
 		$repo = $matches[1];
1127
-		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1267
+		if ($repo == 'http://svn.egroupware.org/egroupware')
1268
+		{
1269
+			$repo = 'svn+ssh://[email protected]/egroupware';
1270
+		}
1128 1271
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
1129 1272
 	}
1130
-	if ($verbose) print_r($config['modules']);
1273
+	if ($verbose)
1274
+	{
1275
+		print_r($config['modules']);
1276
+	}
1131 1277
 	return $config['modules'];
1132 1278
 }
1133 1279
 
@@ -1138,7 +1284,11 @@  discard block
 block discarded – undo
1138 1284
 {
1139 1285
 	global $config,$svn;
1140 1286
 
1141
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1287
+	if (empty($config['svntag']))
1288
+	{
1289
+		return;
1290
+	}
1291
+	// otherwise we copy everything in svn root!
1142 1292
 
1143 1293
 	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1144 1294
 
@@ -1177,11 +1327,17 @@  discard block
 block discarded – undo
1177 1327
 	{
1178 1328
 		$output[] = $cmd;
1179 1329
 		exec($cmd,$output,$ret);
1180
-		if ($verbose) echo implode("\n",$output)."\n";
1330
+		if ($verbose)
1331
+		{
1332
+			echo implode("\n",$output)."\n";
1333
+		}
1181 1334
 	}
1182 1335
 	if ($ret && !in_array($ret,(array)$no_bailout))
1183 1336
 	{
1184
-		if (!$verbose) echo implode("\n",$output)."\n";
1337
+		if (!$verbose)
1338
+		{
1339
+			echo implode("\n",$output)."\n";
1340
+		}
1185 1341
 		throw new Exception("Error during '$cmd' --> aborting",$ret);
1186 1342
 	}
1187 1343
 	return $ret;
@@ -1228,7 +1384,10 @@  discard block
 block discarded – undo
1228 1384
 	unset($config['modules']);	// they give an error, because of nested array and are quite lengthy
1229 1385
 	foreach($config as $name => $default)
1230 1386
 	{
1231
-		if (is_array($default)) $default = implode(' ',$default);
1387
+		if (is_array($default))
1388
+		{
1389
+			$default = implode(' ',$default);
1390
+		}
1232 1391
 		echo '--'.str_pad($name,20).$default."\n";
1233 1392
 	}
1234 1393
 	if ($error)
Please login to merge, or discard this patch.
doc/rpm-build/post_install.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
  *
486 486
  * @param string $cmd
487 487
  * @param array &$output=null $output of command
488
- * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
488
+ * @param integer $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
489 489
  * @return int exit code of $cmd
490 490
  */
491 491
 function run_cmd($cmd,array &$output=null,$no_bailout=null)
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  * Read one Univention secret/password eg. _ucr_secret('mysql')
713 713
  *
714 714
  * @param string $name
715
- * @return string|boolean
715
+ * @return false|string
716 716
  */
717 717
 function _ucr_secret($name)
718 718
 {
Please login to merge, or discard this patch.
Spacing   +80 added lines, -83 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	'php'         => '/usr/bin/php',
19 19
 	'source_dir'  => '/usr/share/egroupware',
20 20
 	'data_dir'    => '/var/lib/egroupware',
21
-	'header'      => '$data_dir/header.inc.php',	// symlinked to source_dir by rpm
21
+	'header'      => '$data_dir/header.inc.php', // symlinked to source_dir by rpm
22 22
 	'setup-cli'   => '$source_dir/setup/setup-cli.php',
23 23
 	'domain'      => 'default',
24 24
 	'config_user' => 'admin',
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	'db_user'     => 'egroupware',
31 31
 	'db_pass'     => randomstring(),
32 32
 	'db_grant_host' => 'localhost',
33
-	'db_root'     => 'root',	// mysql root user/pw to create database
33
+	'db_root'     => 'root', // mysql root user/pw to create database
34 34
 	'db_root_pw'  => '',
35 35
 	'backup'      => '',
36 36
 	'admin_user'  => 'sysop',
37 37
 	'admin_passwd'=> randomstring(),
38 38
 	'admin_email' => '',
39
-	'lang'        => 'en',	// languages for admin user and extra lang to install
39
+	'lang'        => 'en', // languages for admin user and extra lang to install
40 40
 	'charset'     => 'utf-8',
41 41
 	'start_db'    => '/sbin/service mysqld',
42 42
 	'autostart_db' => '/sbin/chkconfig --level 345 mysqld on',
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
 	'ldap_search_filter' => '(uid=%user)',
57 57
 	'ldap_group_context' => 'ou=groups,$base',
58 58
 	'ldap_encryption_type' => '',
59
-	'sambaadmin/sambasid'=> '',	// SID for sambaadmin
59
+	'sambaadmin/sambasid'=> '', // SID for sambaadmin
60 60
 	'mailserver'    => '',
61 61
 	'smtpserver'    => 'localhost,25',
62
-	'smtp'          => '',	// see setup-cli.php --help config
62
+	'smtp'          => '', // see setup-cli.php --help config
63 63
 	'imap'          => '',
64 64
 	'sieve'         => '',
65 65
 	'folder'        => '',
66
-	'install-update-app' => '',	// install or update a single (non-default) app
67
-	'webserver_user'=> 'apache',	// required to fix permissions
66
+	'install-update-app' => '', // install or update a single (non-default) app
67
+	'webserver_user'=> 'apache', // required to fix permissions
68 68
 	'php5enmod'     => '',
69 69
 );
70 70
 
71 71
 // read language from LANG enviroment variable
72 72
 if (($lang = isset($_ENV['LANG']) ? $_ENV['LANG'] : (isset($_SERVER['LANG']) ? $_SERVER['LANG'] : null)))
73 73
 {
74
-	@list($lang,$nat) = preg_split('/[_.]/',$lang);
75
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
74
+	@list($lang, $nat) = preg_split('/[_.]/', $lang);
75
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
76 76
 	{
77 77
 		$lang .= '-'.strtolower($nat);
78 78
 	}
@@ -85,16 +85,13 @@  discard block
 block discarded – undo
85 85
  *
86 86
  * @param string $distro =null default autodetect
87 87
  */
88
-function set_distro_defaults($distro=null)
88
+function set_distro_defaults($distro = null)
89 89
 {
90 90
 	global $config;
91 91
 	if (is_null($distro))
92 92
 	{
93
-		$distro = file_exists('/etc/SuSE-release') ? 'suse' :
94
-			(file_exists('/etc/mandriva-release') ? 'mandriva' :
95
-			(file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
96
-				file_get_contents('/etc/lsb-release')) ? 'univention' :
97
-			(file_exists('/etc/debian_version') ? 'debian' : 'rh')));
93
+		$distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
94
+				file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh')));
98 95
 	}
99 96
 	switch (($config['distro'] = $distro))
100 97
 	{
@@ -162,9 +159,9 @@  discard block
 block discarded – undo
162 159
 			}
163 160
 			elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql'))
164 161
 			{
165
-				foreach(array('start_db','autostart_db') as $name)
162
+				foreach (array('start_db', 'autostart_db') as $name)
166 163
 				{
167
-					$config[$name] = str_replace('mysqld','mysql',$config[$name]);
164
+					$config[$name] = str_replace('mysqld', 'mysql', $config[$name]);
168 165
 				}
169 166
 			}
170 167
 			break;
@@ -180,48 +177,48 @@  discard block
 block discarded – undo
180 177
 if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL']))
181 178
 {
182 179
 	$conf = array();
183
-	$config_set = preg_split('/[ \t]+/',trim($config_set));
184
-	while($config_set)
180
+	$config_set = preg_split('/[ \t]+/', trim($config_set));
181
+	while ($config_set)
185 182
 	{
186 183
 		$val = array_shift($config_set);
187 184
 		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
188 185
 		{
189
-			while (substr($val,-1) != $quote)
186
+			while (substr($val, -1) != $quote)
190 187
 			{
191 188
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
192 189
 				$val .= ' '.array_shift($config_set);
193 190
 			}
194
-			$val = substr($val,1,-1);
191
+			$val = substr($val, 1, -1);
195 192
 		}
196 193
 		$conf[] = $val;
197 194
 	}
198
-	$argv = array_merge($conf,$argv);
195
+	$argv = array_merge($conf, $argv);
199 196
 }
200 197
 
201 198
 $auth_type_given = false;
202
-while(($arg = array_shift($argv)))
199
+while (($arg = array_shift($argv)))
203 200
 {
204 201
 	if ($arg == '-v' || $arg == '--verbose')
205 202
 	{
206 203
 		$verbose = true;
207 204
 	}
208
-	elseif($arg == '-h' || $arg == '--help')
205
+	elseif ($arg == '-h' || $arg == '--help')
209 206
 	{
210 207
 		usage();
211 208
 	}
212
-	elseif($arg == '--suse')
209
+	elseif ($arg == '--suse')
213 210
 	{
214 211
 		set_distro_defaults('suse');
215 212
 	}
216
-	elseif($arg == '--distro')
213
+	elseif ($arg == '--distro')
217 214
 	{
218 215
 		set_distro_defaults(array_shift($argv));
219 216
 	}
220
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
217
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
221 218
 	{
222 219
 		$config[$name] = array_shift($argv);
223 220
 
224
-		switch($name)
221
+		switch ($name)
225 222
 		{
226 223
 			case 'auth_type':
227 224
 				$auth_type_given = true;
@@ -242,18 +239,18 @@  discard block
 block discarded – undo
242 239
 }
243 240
 
244 241
 $replace = array();
245
-foreach($config as $name => $value)
242
+foreach ($config as $name => $value)
246 243
 {
247 244
 	$replace['$'.$name] = $value;
248
-	if (strpos($value,'$') !== false)
245
+	if (strpos($value, '$') !== false)
249 246
 	{
250
-		$config[$name] = strtr($value,$replace);
247
+		$config[$name] = strtr($value, $replace);
251 248
 	}
252 249
 }
253 250
 // basic config checks
254
-foreach(array('php','source_dir','data_dir','setup-cli') as $name)
251
+foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name)
255 252
 {
256
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
253
+	if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!');
257 254
 }
258 255
 
259 256
 // fix important php.ini and conf.d/*.ini settings
@@ -278,7 +275,7 @@  discard block
 block discarded – undo
278 275
 	}
279 276
 	// create database
280 277
 	$setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db';
281
-	foreach(array('domain','db_type','db_host','db_port','db_name','db_user','db_pass','db_root','db_root_pw','db_grant_host') as $name)
278
+	foreach (array('domain', 'db_type', 'db_host', 'db_port', 'db_name', 'db_user', 'db_pass', 'db_root', 'db_root_pw', 'db_grant_host') as $name)
282 279
 	{
283 280
 		$setup_db .= ' '.escapeshellarg($name.'='.$config[$name]);
284 281
 	}
@@ -286,7 +283,7 @@  discard block
 block discarded – undo
286 283
 
287 284
 	// check if ldap is required and initialise it
288 285
 	// we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql!
289
-	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
286
+	@list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3);
290 287
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
291 288
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
292 289
 	if (empty($rest)) unset($config['account-auth']);
@@ -297,15 +294,15 @@  discard block
 block discarded – undo
297 294
 
298 295
 		$setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='.
299 296
 			($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap');
300
-		foreach(array(
301
-			'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw',	// non-egw params: only used for create
302
-			'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context',	// egw params
297
+		foreach (array(
298
+			'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create
299
+			'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params
303 300
 			'ldap_encryption_type', 'sambaadmin/sambasid',
304 301
 		) as $name)
305 302
 		{
306
-			if (strpos($value=$config[$name],'$') !== false)
303
+			if (strpos($value = $config[$name], '$') !== false)
307 304
 			{
308
-				$config[$name] = $value = strtr($value,array(
305
+				$config[$name] = $value = strtr($value, array(
309 306
 					'$suffix' => $config['ldap_suffix'],
310 307
 					'$base' => $config['ldap_base'],
311 308
 					'$admin_pw' => $config['ldap_admin_pw'],
@@ -313,7 +310,7 @@  discard block
 block discarded – undo
313 310
 			}
314 311
 			$setup_ldap .= ' '.escapeshellarg($name.'='.$value);
315 312
 
316
-			if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw')))
313
+			if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw')))
317 314
 			{
318 315
 				$extra_config .= ' '.escapeshellarg($name.'='.$value);
319 316
 			}
@@ -346,7 +343,7 @@  discard block
 block discarded – undo
346 343
 	}
347 344
 	// create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error)
348 345
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
349
-	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
346
+	foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name)
350 347
 	{
351 348
 		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
352 349
 	}
@@ -360,7 +357,7 @@  discard block
 block discarded – undo
360 357
 	// check if webserver is started and start it (permanent) if not
361 358
 	if ($config['start_webserver'])
362 359
 	{
363
-		exec(build_cmd('start_webserver', 'status'),$dummy,$ret);
360
+		exec(build_cmd('start_webserver', 'status'), $dummy, $ret);
364 361
 		if ($ret)
365 362
 		{
366 363
 			system(build_cmd('start_webserver', 'start'));
@@ -399,7 +396,7 @@  discard block
 block discarded – undo
399 396
 	// --> existing install --> update
400 397
 
401 398
 	// get user from header and replace password, as we dont know it
402
-	$old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']);
399
+	$old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']);
403 400
 	// register a shutdown function to put old password back in any case
404 401
 	register_shutdown_function(function() use (&$config, $old_password)
405 402
 	{
@@ -408,18 +405,18 @@  discard block
 block discarded – undo
408 405
 
409 406
 	// update egroupware
410 407
 	$setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd'].',,'.$config['install-update-app']);
411
-	$ret = run_cmd($setup_update,$output,array(4,15));
408
+	$ret = run_cmd($setup_update, $output, array(4, 15));
412 409
 
413
-	switch($ret)
410
+	switch ($ret)
414 411
 	{
415 412
 		case 4:		// header needs an update
416 413
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
417 414
 			run_cmd($header_update);
418
-			$ret = run_cmd($setup_update,$output,15);
415
+			$ret = run_cmd($setup_update, $output, 15);
419 416
 			if ($ret != 15) break;
420 417
 			// fall through
421 418
 		case 15:	// missing configuration (eg. mailserver)
422
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
419
+			if (!$verbose) echo implode("\n", (array)$output)."\n";
423 420
 			break;
424 421
 
425 422
 		case 0:
@@ -462,18 +459,18 @@  discard block
 block discarded – undo
462 459
  * @param string $password new password
463 460
  * @return string old password
464 461
  */
465
-function patch_header($filename,&$user,$password)
462
+function patch_header($filename, &$user, $password)
466 463
 {
467 464
 	$header = file_get_contents($filename);
468 465
 
469 466
 	$umatches = $pmatches = null;
470
-	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) ||
471
-		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches))
467
+	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) ||
468
+		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches))
472 469
 	{
473
-		bail_out(99,"$filename is no regular EGroupware header.inc.php!");
470
+		bail_out(99, "$filename is no regular EGroupware header.inc.php!");
474 471
 	}
475
-	file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
476
-		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header));
472
+	file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
473
+		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header));
477 474
 
478 475
 	$user = $umatches[1];
479 476
 
@@ -488,7 +485,7 @@  discard block
 block discarded – undo
488 485
  * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
489 486
  * @return int exit code of $cmd
490 487
  */
491
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
488
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
492 489
 {
493 490
 	global $verbose;
494 491
 
@@ -496,16 +493,16 @@  discard block
 block discarded – undo
496 493
 	{
497 494
 		echo $cmd."\n";
498 495
 		$ret = null;
499
-		system($cmd,$ret);
496
+		system($cmd, $ret);
500 497
 	}
501 498
 	else
502 499
 	{
503 500
 		$output[] = $cmd;
504
-		exec($cmd,$output,$ret);
501
+		exec($cmd, $output, $ret);
505 502
 	}
506
-	if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout))
503
+	if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout))
507 504
 	{
508
-		bail_out($ret,$verbose?null:$output);
505
+		bail_out($ret, $verbose ? null : $output);
509 506
 	}
510 507
 	return $ret;
511 508
 }
@@ -516,9 +513,9 @@  discard block
 block discarded – undo
516 513
  * @param int $ret =1
517 514
  * @param array|string $output line(s) to output before temination notice
518 515
  */
519
-function bail_out($ret=1,$output=null)
516
+function bail_out($ret = 1, $output = null)
520 517
 {
521
-	if ($output) echo implode("\n",(array)$output);
518
+	if ($output) echo implode("\n", (array)$output);
522 519
 	echo "\n\nInstallation failed --> exiting!\n\n";
523 520
 	exit($ret);
524 521
 }
@@ -529,21 +526,21 @@  discard block
 block discarded – undo
529 526
  * @param int $len =16
530 527
  * @return string
531 528
  */
532
-function randomstring($len=16)
529
+function randomstring($len = 16)
533 530
 {
534 531
 	static $usedchars = array(
535
-		'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
536
-		'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
537
-		'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
538
-		'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
539
-		'@','!','%','&','(',')','=','?',';',':','#','_','-','<',
540
-		'>','|','[',']','}',	// dont add /\,'"{ as we have problems dealing with them
532
+		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
533
+		'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
534
+		'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
535
+		'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
536
+		'@', '!', '%', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<',
537
+		'>', '|', '[', ']', '}', // dont add /\,'"{ as we have problems dealing with them
541 538
 	);
542 539
 
543 540
 	$str = '';
544
-	for($i=0; $i < $len; $i++)
541
+	for ($i = 0; $i < $len; $i++)
545 542
 	{
546
-		$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
543
+		$str .= $usedchars[mt_rand(0, count($usedchars) - 1)];
547 544
 	}
548 545
 	return $str;
549 546
 }
@@ -553,20 +550,20 @@  discard block
 block discarded – undo
553 550
  *
554 551
  * @param string $error =null optional error-message
555 552
  */
556
-function usage($error=null)
553
+function usage($error = null)
557 554
 {
558
-	global $prog,$config;
555
+	global $prog, $config;
559 556
 
560 557
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n";
561 558
 	echo "options and their defaults:\n";
562
-	foreach($config as $name => $default)
559
+	foreach ($config as $name => $default)
563 560
 	{
564
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
565
-		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
561
+		if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options
562
+		if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16)
566 563
 		{
567 564
 			$default = '<16 char random string>';
568 565
 		}
569
-		echo '--'.str_pad($name,20).$default."\n";
566
+		echo '--'.str_pad($name, 20).$default."\n";
570 567
 	}
571 568
 	if ($error)
572 569
 	{
@@ -616,8 +613,8 @@  discard block
 block discarded – undo
616 613
 	$config['distro'] = 'univention';
617 614
 
618 615
 	// set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment
619
-	@list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
620
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
616
+	@list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
617
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
621 618
 	{
622 619
 		$lang .= '-'.strtolower($nat);
623 620
 	}
@@ -642,7 +639,7 @@  discard block
 block discarded – undo
642 639
 		// ldap password hash (our default blowfish_crypt seems not to work)
643 640
 		$config['ldap_encryption_type'] = 'sha512_crypt';
644 641
 
645
-		$config['account_min_id'] = 1200;	// UCS use 11xx for internal users/groups
642
+		$config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups
646 643
 
647 644
 		$config['account-auth'] = 'univention,ldap';
648 645
 
@@ -652,7 +649,7 @@  discard block
 block discarded – undo
652 649
 		// mailserver, see setup-cli.php --help config
653 650
 		if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) &&
654 651
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
655
-			($domains=_ucr_get('mail/hosteddomains')))
652
+			($domains = _ucr_get('mail/hosteddomains')))
656 653
 		{
657 654
 			if (!is_array($domains)) $domains = explode("\n", $domains);
658 655
 			$domain = array_shift($domains);
@@ -692,12 +689,12 @@  discard block
 block discarded – undo
692 689
  */
693 690
 function _ucr_get($name)
694 691
 {
695
-	static $values=null;
692
+	static $values = null;
696 693
 	if (!isset($values))
697 694
 	{
698 695
 		$output = $matches = null;
699 696
 		exec('/usr/sbin/ucr dump', $output);
700
-		foreach($output as $line)
697
+		foreach ($output as $line)
701 698
 		{
702 699
 			if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches))
703 700
 			{
@@ -773,7 +770,7 @@  discard block
 block discarded – undo
773 770
  */
774 771
 function _size_with_unit($size)
775 772
 {
776
-	switch(strtoupper(substr($size, -1)))
773
+	switch (strtoupper(substr($size, -1)))
777 774
 	{
778 775
 		case 'G':
779 776
 			$size *= 1024;
Please login to merge, or discard this patch.
Braces   +90 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,10 +9,13 @@  discard block
 block discarded – undo
9 9
  * @version $Id$
10 10
  */
11 11
 
12
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling post_install as web-page
12
+if (php_sapi_name() !== 'cli')
13
+{
14
+	// security precaution: forbit calling post_install as web-page
13 15
 {
14 16
 	die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>');
15 17
 }
18
+}
16 19
 $verbose = false;
17 20
 $config = array(
18 21
 	'php'         => '/usr/bin/php',
@@ -100,7 +103,10 @@  discard block
 block discarded – undo
100 103
 	{
101 104
 		case 'suse':
102 105
 			// openSUSE 12.1+ no longer uses php5
103
-			if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5';
106
+			if (file_exists('/usr/bin/php5'))
107
+			{
108
+				$config['php'] = '/usr/bin/php5';
109
+			}
104 110
 			$config['start_db'] = '/sbin/service mysql';
105 111
 			$config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on';
106 112
 			$config['start_webserver'] = '/sbin/service apache2';
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 			{
131 137
 				$config['php5enmod'] = '/usr/sbin/php5enmod';
132 138
 				// Ubuntu only needs "-s ALL" and Debian gives an error, because it does not support it
133
-				if (!file_exists('/etc/php5/conf.d/')) $config['php5enmod'] .= ' -s ALL';
139
+				if (!file_exists('/etc/php5/conf.d/'))
140
+				{
141
+					$config['php5enmod'] .= ' -s ALL';
142
+				}
134 143
 				$config['php5enmod'] .= ' mcrypt';
135 144
 			}
136 145
 			$config['autostart_db'] = '/usr/sbin/update-rc.d mysql defaults';
@@ -153,9 +162,12 @@  discard block
 block discarded – undo
153 162
 			// fall through
154 163
 		case 'rh':
155 164
 			// some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld"
156
-			if (file_exists('/usr/bin/systemctl'))	// RHEL 7
165
+			if (file_exists('/usr/bin/systemctl'))
166
+			{
167
+				// RHEL 7
157 168
 			{
158 169
 				$config['start_db'] = '/usr/bin/systemctl %s mariadb';
170
+			}
159 171
 				$config['autostart_db'] = build_cmd('start_db', 'enable');
160 172
 				$config['start_webserver'] = '/usr/bin/systemctl %s httpd';
161 173
 				$config['autostart_webserver'] = build_cmd('start_webserver', 'enable');
@@ -184,11 +196,14 @@  discard block
 block discarded – undo
184 196
 	while($config_set)
185 197
 	{
186 198
 		$val = array_shift($config_set);
187
-		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
199
+		if (($quote = $val[0]) == "'" || $quote == '"')
200
+		{
201
+			// arguments might be quoted with ' or "
188 202
 		{
189 203
 			while (substr($val,-1) != $quote)
190 204
 			{
191 205
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
206
+		}
192 207
 				$val .= ' '.array_shift($config_set);
193 208
 			}
194 209
 			$val = substr($val,1,-1);
@@ -253,18 +268,24 @@  discard block
 block discarded – undo
253 268
 // basic config checks
254 269
 foreach(array('php','source_dir','data_dir','setup-cli') as $name)
255 270
 {
256
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
257
-}
271
+	if (!file_exists($config[$name]))
272
+	{
273
+		bail_out(1,$config[$name].' not found!');
274
+	}
275
+	}
258 276
 
259 277
 // fix important php.ini and conf.d/*.ini settings
260 278
 check_fix_php_apc_ini();
261 279
 
262 280
 $setup_cli = $config['php'].' -d memory_limit=256M '.$config['setup-cli'];
263 281
 
264
-if (!file_exists($config['header']) || filesize($config['header']) < 200)	// default header redirecting to setup is 147 bytes
282
+if (!file_exists($config['header']) || filesize($config['header']) < 200)
283
+{
284
+	// default header redirecting to setup is 147 bytes
265 285
 {
266 286
 	// --> new install
267 287
 	$extra_config = '';
288
+}
268 289
 
269 290
 	// check for localhost if database server is started and start it (permanent) if not
270 291
 	if ($config['db_host'] == 'localhost' && $config['start_db'])
@@ -273,7 +294,10 @@  discard block
 block discarded – undo
273 294
 		if ($ret)
274 295
 		{
275 296
 			system(build_cmd('start_db', 'start'));
276
-			if (!empty($config['autostart_db'])) system($config['autostart_db']);
297
+			if (!empty($config['autostart_db']))
298
+			{
299
+				system($config['autostart_db']);
300
+			}
277 301
 		}
278 302
 	}
279 303
 	// create database
@@ -289,7 +313,10 @@  discard block
 block discarded – undo
289 313
 	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
290 314
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
291 315
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
292
-	if (empty($rest)) unset($config['account-auth']);
316
+	if (empty($rest))
317
+	{
318
+		unset($config['account-auth']);
319
+	}
293 320
 	if ($config['account_repository'] == 'ldap' || $config['auth_type'] == 'ldap')
294 321
 	{
295 322
 		// set account_min_id to 1100 if not specified to NOT clash with system accounts
@@ -348,7 +375,10 @@  discard block
 block discarded – undo
348 375
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
349 376
 	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
350 377
 	{
351
-		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
378
+		if (!empty($config[$name]))
379
+		{
380
+			$setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
381
+		}
352 382
 	}
353 383
 	run_cmd($setup_mailserver);
354 384
 
@@ -364,7 +394,10 @@  discard block
 block discarded – undo
364 394
 		if ($ret)
365 395
 		{
366 396
 			system(build_cmd('start_webserver', 'start'));
367
-			if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']);
397
+			if (!empty($config['autostart_webserver']))
398
+			{
399
+				system($config['autostart_webserver']);
400
+			}
368 401
 		}
369 402
 		else
370 403
 		{
@@ -416,10 +449,16 @@  discard block
 block discarded – undo
416 449
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
417 450
 			run_cmd($header_update);
418 451
 			$ret = run_cmd($setup_update,$output,15);
419
-			if ($ret != 15) break;
452
+			if ($ret != 15)
453
+			{
454
+				break;
455
+			}
420 456
 			// fall through
421 457
 		case 15:	// missing configuration (eg. mailserver)
422
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
458
+			if (!$verbose)
459
+			{
460
+				echo implode("\n",(array)$output)."\n";
461
+			}
423 462
 			break;
424 463
 
425 464
 		case 0:
@@ -447,9 +486,15 @@  discard block
 block discarded – undo
447 486
 {
448 487
 	global $config;
449 488
 
450
-	if (isset($config[$cmd])) $cmd = $config[$cmd];
489
+	if (isset($config[$cmd]))
490
+	{
491
+		$cmd = $config[$cmd];
492
+	}
451 493
 
452
-	if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd);
494
+	if (strpos($cmd, '%s'))
495
+	{
496
+		return str_replace('%s', $arg, $cmd);
497
+	}
453 498
 
454 499
 	return $cmd.' '.$arg;
455 500
 }
@@ -518,7 +563,10 @@  discard block
 block discarded – undo
518 563
  */
519 564
 function bail_out($ret=1,$output=null)
520 565
 {
521
-	if ($output) echo implode("\n",(array)$output);
566
+	if ($output)
567
+	{
568
+		echo implode("\n",(array)$output);
569
+	}
522 570
 	echo "\n\nInstallation failed --> exiting!\n\n";
523 571
 	exit($ret);
524 572
 }
@@ -561,7 +609,11 @@  discard block
 block discarded – undo
561 609
 	echo "options and their defaults:\n";
562 610
 	foreach($config as $name => $default)
563 611
 	{
564
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
612
+		if (in_array($name, array('postfix','cyrus')))
613
+		{
614
+			continue;
615
+		}
616
+		// do NOT report deprecated options
565 617
 		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
566 618
 		{
567 619
 			$default = '<16 char random string>';
@@ -654,7 +706,10 @@  discard block
 block discarded – undo
654 706
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
655 707
 			($domains=_ucr_get('mail/hosteddomains')))
656 708
 		{
657
-			if (!is_array($domains)) $domains = explode("\n", $domains);
709
+			if (!is_array($domains))
710
+			{
711
+				$domains = explode("\n", $domains);
712
+			}
658 713
 			$domain = array_shift($domains);
659 714
 			// set "use auth with session credentials",tls,"not user editable","further identities"
660 715
 			$config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes";
@@ -664,13 +719,19 @@  discard block
 block discarded – undo
664 719
 			{
665 720
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Dovecot';
666 721
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
667
-				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190;
722
+				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port')))
723
+				{
724
+					$sieve_port = 4190;
725
+				}
668 726
 			}
669 727
 			else
670 728
 			{
671 729
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus';
672 730
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
673
-				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190;
731
+				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port')))
732
+				{
733
+					$sieve_port = 4190;
734
+				}
674 735
 			}
675 736
 			// set folders so mail creates them on first login, UCS does not automatic
676 737
 			$config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,INBOX/Spam';
@@ -735,7 +796,10 @@  discard block
 block discarded – undo
735 796
 		$shm_size = ini_get('apc.shm_size');
736 797
 		$shm_segments = ini_get('apc.shm_segments');
737 798
 		// ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit
738
-		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M';
799
+		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576))
800
+		{
801
+			$shm_size .= 'M';
802
+		}
739 803
 
740 804
 		$size = _size_with_unit($shm_size) * $shm_segments;
741 805
 		//echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n";
@@ -751,7 +815,10 @@  discard block
 block discarded – undo
751 815
 				file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path)))
752 816
 			{
753 817
 				$new_shm_size = 128 / $shm_segments;
754
-				if (!$numeric_size) $new_shm_size .= 'M';
818
+				if (!$numeric_size)
819
+				{
820
+					$new_shm_size .= 'M';
821
+				}
755 822
 				if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini))
756 823
 				{
757 824
 					file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini));
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_hooks.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 	/**
92 92
 	 * Entries for filemanagers's admin menu
93 93
 	 *
94
-	 * @param string|array $location ='admin' hook name or params
94
+	 * @param string $location ='admin' hook name or params
95 95
 	 */
96 96
 	static function admin($location = 'admin')
97 97
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		);
106 106
 		if ($location == 'admin')
107 107
 		{
108
-        	display_section(self::$appname,$file);
108
+			display_section(self::$appname,$file);
109 109
 		}
110 110
 		else
111 111
 		{
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 			'yes' => lang('Yes')
129 129
 		);
130 130
 
131
-        $settings = array(
131
+		$settings = array(
132 132
 			'startfolder'	=> array(
133 133
 				'type'		=> 'input',
134 134
 				'name'		=> 'startfolder',
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
35 35
 		$config = config::read(self::$appname);
36 36
 		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
37
-		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
37
+		$file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
38 38
 		if ($location == 'sidebox_menu')
39 39
 		{
40
-			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu');
40
+			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu');
41 41
 			$file = array();
42
-			if($GLOBALS['egw_info']['apps']['stylite'])
42
+			if ($GLOBALS['egw_info']['apps']['stylite'])
43 43
 			{
44 44
 				// add "file a file" (upload) dialog
45 45
 				$file[] = array(
46 46
 					'text' => 'File a file',
47
-					'link' => "javascript:egw_openWindowCentered2('".egw::link('/index.php',array(
47
+					'link' => "javascript:egw_openWindowCentered2('".egw::link('/index.php', array(
48 48
 							'menuaction'=>'stylite.stylite_filemanager.upload',
49
-						),false)."','_blank',550,350)",
49
+						), false)."','_blank',550,350)",
50 50
 					'app'  => 'phpgwapi',
51 51
 					'icon' => 'upload',
52 52
 				);
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 			// add selection for available views, if we have more then one
55 55
 			if (count(filemanager_ui::init_views()) > 1)
56 56
 			{
57
-				$index_url = egw::link('/index.php',array('menuaction' => 'filemanager.filemanager_ui.index'),false);
57
+				$index_url = egw::link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index'), false);
58 58
 				$file[] = array(
59
-					'text' => html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false,
59
+					'text' => html::select('filemanager_view', filemanager_ui::get_view(), filemanager_ui::$views, false,
60 60
 						' onchange="'."egw_appWindow('filemanager').location='$index_url&view='+this.value;".
61 61
 						'" style="width: 100%;"'),
62 62
 					'no_lang' => True,
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 			}
66 66
 			if ($file_prefs['showhome'] != 'no')
67 67
 			{
68
-				$file['Your home directory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$homepath,'ajax'=>'true'));
68
+				$file['Your home directory'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$homepath, 'ajax'=>'true'));
69 69
 			}
70 70
 			if ($file_prefs['showusers'] != 'no')
71 71
 			{
72
-				$file['Users and groups'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$basepath,'ajax'=>'true'));
72
+				$file['Users and groups'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$basepath, 'ajax'=>'true'));
73 73
 			}
74
-			if (!empty($file_prefs['showbase']) && $file_prefs['showbase']=='yes')
74
+			if (!empty($file_prefs['showbase']) && $file_prefs['showbase'] == 'yes')
75 75
 			{
76
-				$file['Basedirectory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true'));
76
+				$file['Basedirectory'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$rootpath, 'ajax'=>'true'));
77 77
 			}
78
-			if (!empty($file_prefs['startfolder'])) $file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
79
-			for ($i=1; $i<=self::$foldercount; $i++)
78
+			if (!empty($file_prefs['startfolder'])) $file['Startfolder'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true'));
79
+			for ($i = 1; $i <= self::$foldercount; $i++)
80 80
 			{
81 81
 				if (!empty($file_prefs['folderlink'.$i]))
82 82
 				{
83
-					$foldername = array_pop(explode('/',$file_prefs['folderlink'.$i]));
84
-					$file[lang('Link %1: %2',$i,$foldername)]= egw::link('/index.php',array(
83
+					$foldername = array_pop(explode('/', $file_prefs['folderlink'.$i]));
84
+					$file[lang('Link %1: %2', $i, $foldername)] = egw::link('/index.php', array(
85 85
 						'menuaction' => self::$appname.'.filemanager_ui.index',
86 86
 						'path'       => $file_prefs['folderlink'.$i],
87 87
 						'nolang'     => true,
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 					));
90 90
 				}
91 91
 			}
92
-			$file['Placeholders'] = egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements');
93
-			$file['Shared files'] = egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
94
-			display_sidebox(self::$appname,$title,$file);
92
+			$file['Placeholders'] = egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements');
93
+			$file['Shared files'] = egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true');
94
+			display_sidebox(self::$appname, $title, $file);
95 95
 		}
96 96
 		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
97 97
 	}
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 		if (is_array($location)) $location = $location['location'];
107 107
 
108 108
 		$file = Array(
109
-			'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname='.self::$appname),
110
-			'Custom fields' => egw::link('/index.php','menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'),
111
-			'Check virtual filesystem' => egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'),
109
+			'Site Configuration' => egw::link('/index.php', 'menuaction=admin.uiconfig.index&appname='.self::$appname),
110
+			'Custom fields' => egw::link('/index.php', 'menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'),
111
+			'Check virtual filesystem' => egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'),
112 112
 			'VFS mounts and versioning' => egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'),
113 113
 		);
114 114
 		if ($location == 'admin')
115 115
 		{
116
-        	display_section(self::$appname,$file);
116
+        	display_section(self::$appname, $file);
117 117
 		}
118 118
 		else
119 119
 		{
120
-			display_sidebox(self::$appname,lang('Admin'),$file);
120
+			display_sidebox(self::$appname, lang('Admin'), $file);
121 121
 		}
122 122
 	}
123 123
 
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 				'admin'		=> False,
148 148
 			),
149 149
 		);
150
-		for ($i=1; $i <= self::$foldercount; $i++)
150
+		for ($i = 1; $i <= self::$foldercount; $i++)
151 151
 		{
152
-			$settings['folderlink'.$i]	= array(
152
+			$settings['folderlink'.$i] = array(
153 153
 				'type'		=> 'input',
154 154
 				'name'		=> 'folderlink'.$i,
155 155
 				'size'		=> 60,
156 156
 				'default'	=> '',
157 157
 				'label' 	=> lang('Enter the complete VFS path to specify a fast access link to a folder').' ('.$i.').',
158
-				'run_lang'  => -1,	// -1 = no lang on label
158
+				'run_lang'  => -1, // -1 = no lang on label
159 159
 				'xmlrpc'	=> True,
160 160
 				'admin'		=> False
161 161
 			);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 				'type'		=> 'select',
177 177
 				'name'		=> 'showhome',
178 178
 				'values'	=> $yes_no,
179
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Your home directory')),
179
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Your home directory')),
180 180
 				'xmlrpc'	=> True,
181 181
 				'admin'		=> False,
182 182
 				'forced'   => 'yes',
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				'type'		=> 'select',
186 186
 				'name'		=> 'showusers',
187 187
 				'values'	=> $yes_no,
188
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Users and groups')),
188
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Users and groups')),
189 189
 				'xmlrpc'	=> True,
190 190
 				'admin'		=> False,
191 191
 				'forced'   => 'yes',
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 			'size'   => 60,
198 198
 			'label'  => 'Default document to insert entries',
199 199
 			'name'   => 'default_document',
200
-			'help'   => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('filemanager')).' '.
200
+			'help'   => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('filemanager')).' '.
201 201
 				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
202
-				lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
202
+				lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()),
203 203
 			'run_lang' => false,
204 204
 			'xmlrpc' => True,
205 205
 			'admin'  => False,
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 			'label'  => 'Directory with documents to insert entries',
211 211
 			'name'   => 'document_dir',
212 212
 			'help'   => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('filemanager')).' '.
213
-				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '.
214
-				lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
213
+				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
214
+				lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()),
215 215
 			'run_lang' => false,
216 216
 			'xmlrpc' => True,
217 217
 			'admin'  => False,
Please login to merge, or discard this patch.
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,10 @@  discard block
 block discarded – undo
33 33
 		$homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
34 34
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
35 35
 		$config = config::read(self::$appname);
36
-		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
36
+		if (!empty($config['max_folderlinks']))
37
+		{
38
+			self::$foldercount = (int)$config['max_folderlinks'];
39
+		}
37 40
 		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
38 41
 		if ($location == 'sidebox_menu')
39 42
 		{
@@ -75,7 +78,10 @@  discard block
 block discarded – undo
75 78
 			{
76 79
 				$file['Basedirectory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true'));
77 80
 			}
78
-			if (!empty($file_prefs['startfolder'])) $file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
81
+			if (!empty($file_prefs['startfolder']))
82
+			{
83
+				$file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
84
+			}
79 85
 			for ($i=1; $i<=self::$foldercount; $i++)
80 86
 			{
81 87
 				if (!empty($file_prefs['folderlink'.$i]))
@@ -93,7 +99,10 @@  discard block
 block discarded – undo
93 99
 			$file['Shared files'] = egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
94 100
 			display_sidebox(self::$appname,$title,$file);
95 101
 		}
96
-		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
102
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
103
+		{
104
+			self::admin(self::$appname);
105
+		}
97 106
 	}
98 107
 
99 108
 	/**
@@ -103,7 +112,10 @@  discard block
 block discarded – undo
103 112
 	 */
104 113
 	static function admin($location = 'admin')
105 114
 	{
106
-		if (is_array($location)) $location = $location['location'];
115
+		if (is_array($location))
116
+		{
117
+			$location = $location['location'];
118
+		}
107 119
 
108 120
 		$file = Array(
109 121
 			'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname='.self::$appname),
@@ -129,7 +141,10 @@  discard block
 block discarded – undo
129 141
 	static function settings()
130 142
 	{
131 143
 		$config = config::read(self::$appname);
132
-		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
144
+		if (!empty($config['max_folderlinks']))
145
+		{
146
+			self::$foldercount = (int)$config['max_folderlinks'];
147
+		}
133 148
 
134 149
 		$yes_no = array(
135 150
 			'no'  => lang('No'),
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
 		unset($args);	// unused, but required by function signature
466 466
 		$appname = 'preferences';
467
-		$file = Array(
467
+		$file = array(
468 468
 			'Site configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
469 469
 		);
470 470
 		display_section($appname, $file);
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_shares.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@
 block discarded – undo
127 127
 	/**
128 128
 	 * Show files shared
129 129
 	 *
130
-	 * @param array $content=null
131
-	 * @param string $msg=''
130
+	 * @param array $content
132 131
 	 */
133 132
 	public function index(array $content=null)
134 133
 	{
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,10 @@
 block discarded – undo
101 101
 				$row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY;
102 102
 			}
103 103
 			$row['share_passwd'] = (boolean)$row['share_passwd'];
104
-			if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']);
104
+			if ($row['share_with'])
105
+			{
106
+				$row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']);
107
+			}
105 108
 		}
106 109
 		return $total;
107 110
 	}
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		// sudo handling
42 42
 		parent::__construct();
43
-		self::$is_setup = egw_session::appsession('is_setup','filemanager');
43
+		self::$is_setup = egw_session::appsession('is_setup', 'filemanager');
44 44
 		self::$tmp_dir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/';
45 45
 	}
46 46
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$readonlys = null;
85 85
 		$total = egw_sharing::so()->get_rows($query, $rows, $readonlys);
86 86
 
87
-		foreach($rows as &$row)
87
+		foreach ($rows as &$row)
88 88
 		{
89 89
 			if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir)
90 90
 			{
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
 	 * @param array $content=null
126 126
 	 * @param string $msg=''
127 127
 	 */
128
-	public function index(array $content=null)
128
+	public function index(array $content = null)
129 129
 	{
130 130
 		if (!is_array($content))
131 131
 		{
132 132
 			$content = array(
133 133
 				'nm' => array(
134
-					'get_rows'       =>	'filemanager.filemanager_shares.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
135
-					'no_filter'      => True,	// current dir only
136
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
137
-					'no_cat'         => True,	// I  disable the cat-selectbox
138
-					'lettersearch'   => false,	// I  show a lettersearch
139
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
140
-					'start'          =>	0,		// IO position in list
141
-					'order'          =>	'share_created',	// IO name of the column to sort after (optional for the sortheaders)
142
-					'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
134
+					'get_rows'       =>	'filemanager.filemanager_shares.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
135
+					'no_filter'      => True, // current dir only
136
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
137
+					'no_cat'         => True, // I  disable the cat-selectbox
138
+					'lettersearch'   => false, // I  show a lettersearch
139
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
140
+					'start'          =>	0, // IO position in list
141
+					'order'          =>	'share_created', // IO name of the column to sort after (optional for the sortheaders)
142
+					'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
143 143
 					//'default_cols'   => '!',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
144 144
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
145 145
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		elseif ($content['nm']['action'])
153 153
 		{
154
-			switch($content['nm']['action'])
154
+			switch ($content['nm']['action'])
155 155
 			{
156 156
 				case 'delete':
157 157
 					$where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']);
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_ui.inc.php 4 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -536,6 +536,9 @@  discard block
 block discarded – undo
536 536
 	 * @param int &$errs=null on return number of errors
537 537
 	 * @param int &$dirs=null on return number of dirs deleted
538 538
 	 * @param int &$files=null on return number of files deleted
539
+	 * @param integer $errs
540
+	 * @param integer $files
541
+	 * @param integer $dirs
539 542
 	 * @return string success or failure message displayed to the user
540 543
 	 */
541 544
 	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
@@ -704,6 +707,9 @@  discard block
 block discarded – undo
704 707
 	 * @param int &$errs=null on return number of errors
705 708
 	 * @param int &$dirs=null on return number of dirs deleted
706 709
 	 * @param int &$files=null on return number of files deleted
710
+	 * @param integer $errs
711
+	 * @param integer $dirs
712
+	 * @param integer $files
707 713
 	 * @return string
708 714
 	 */
709 715
 	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
@@ -1325,7 +1331,6 @@  discard block
 block discarded – undo
1325 1331
 	 *
1326 1332
 	 * @param string $action eg. 'delete', ...
1327 1333
 	 * @param array $selected selected path(s)
1328
-	 * @param string $dir=null current directory
1329 1334
 	 * @see static::action()
1330 1335
 	 */
1331 1336
 	public static function ajax_action($action, $selected, $dir=null, $props=null)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1420,7 +1420,7 @@
 block discarded – undo
1420 1420
 					if (Vfs::file_exists($target) && $app_dir)
1421 1421
 					{
1422 1422
 						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1423
-						error_log("Symlinking $target to $app_dir");
1423
+						error_log("symlinking $target to $app_dir");
1424 1424
 						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1425 1425
 					}
1426 1426
 				}
Please login to merge, or discard this patch.
Spacing   +204 added lines, -206 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			$_GET = etemplate::array_stripslashes($_GET);
54 54
 		}
55 55
 		// do we have root rights
56
-		if (egw_session::appsession('is_root','filemanager'))
56
+		if (egw_session::appsession('is_root', 'filemanager'))
57 57
 		{
58 58
 			egw_vfs::$is_root = true;
59 59
 		}
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 		if (!static::$views_init)
73 73
 		{
74 74
 			// translate our labels
75
-			foreach(static::$views as &$label)
75
+			foreach (static::$views as &$label)
76 76
 			{
77 77
 				$label = lang($label);
78 78
 			}
79 79
 			// search for plugins with additional filemanager views
80
-			foreach($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
80
+			foreach ($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
81 81
 			{
82 82
 				if (is_array($views)) static::$views += $views;
83 83
 			}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public static function get_view()
95 95
 	{
96
-		$view =& egw_cache::getSession('filemanager', 'view');
96
+		$view = & egw_cache::getSession('filemanager', 'view');
97 97
 		if (isset($_GET['view']))
98 98
 		{
99 99
 			$view = $_GET['view'];
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			'open' => array(
118 118
 				'caption' => lang('Open'),
119 119
 				'icon' => '',
120
-				'group' => $group=1,
120
+				'group' => $group = 1,
121 121
 				'allowOnMultiple' => false,
122 122
 				'onExecute' => 'javaScript:app.filemanager.open',
123 123
 				'default' => true
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			),
171 171
 			// DRAG and DROP events
172 172
 			'file_drag' => array(
173
-				'dragType' => array('file','link'),
173
+				'dragType' => array('file', 'link'),
174 174
 				'type' => 'drag',
175 175
 				'onExecute' => 'javaScript:app.filemanager.drag'
176 176
 			),
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 		else
211 211
 		{
212
-			foreach(egw_sharing::$modes as $mode => $data)
212
+			foreach (egw_sharing::$modes as $mode => $data)
213 213
 			{
214 214
 				$actions['mail']['children']['mail_'.$mode] = array(
215 215
 					'caption' => $data['label'],
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return string merge application or NULL if no property found
233 233
 	 */
234
-	private static function get_mergeapp($path, $scope='self')
234
+	private static function get_mergeapp($path, $scope = 'self')
235 235
 	{
236 236
 		$app = null;
237
-		switch($scope)
237
+		switch ($scope)
238 238
 		{
239 239
 			case 'self':
240 240
 				$props = egw_vfs::propfind($path, static::$merge_prop_namespace);
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 			case 'parents':
244 244
 				// search for props in parent directories
245 245
 				$currentpath = $path;
246
-				while($dir = egw_vfs::dirname($currentpath))
246
+				while ($dir = egw_vfs::dirname($currentpath))
247 247
 				{
248 248
 					$props = egw_vfs::propfind($dir, static::$merge_prop_namespace);
249
-					if(!empty($props))
249
+					if (!empty($props))
250 250
 					{
251 251
 						// found prop in parent directory
252 252
 						return $app = $props[0]['val'];
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 	 * @param array $content
266 266
 	 * @param string $msg
267 267
 	 */
268
-	function index(array $content=null,$msg=null)
268
+	function index(array $content = null, $msg = null)
269 269
 	{
270 270
 		if (!is_array($content))
271 271
 		{
272 272
 			$content = array(
273
-				'nm' => egw_session::appsession('index','filemanager'),
273
+				'nm' => egw_session::appsession('index', 'filemanager'),
274 274
 			);
275 275
 			if (!is_array($content['nm']))
276 276
 			{
277 277
 				$content['nm'] = array(
278
-					'get_rows'       =>	'filemanager.filemanager_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
279
-					'filter'         => '',	// current dir only
280
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
281
-					'no_cat'         => True,	// I  disable the cat-selectbox
282
-					'lettersearch'   => True,	// I  show a lettersearch
283
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
284
-					'start'          =>	0,		// IO position in list
285
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
286
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
287
-					'default_cols'   => '!comment,ctime',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
278
+					'get_rows'       =>	'filemanager.filemanager_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
279
+					'filter'         => '', // current dir only
280
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
281
+					'no_cat'         => True, // I  disable the cat-selectbox
282
+					'lettersearch'   => True, // I  show a lettersearch
283
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
284
+					'start'          =>	0, // IO position in list
285
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
286
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
287
+					'default_cols'   => '!comment,ctime', // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
288 288
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
289 289
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
290 290
 					'actions'        => static::get_actions(),
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 					'is_parent_value'=> egw_vfs::DIR_MIME_TYPE,
296 296
 					'header_left'    => 'filemanager.index.header_left',
297 297
 					'favorites'      => true,
298
-					'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
298
+					'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink')
299 299
 				);
300 300
 				$content['nm']['path'] = static::get_home_dir();
301 301
 			}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 			}
317 317
 			if (isset($_GET['path']) && ($path = $_GET['path']))
318 318
 			{
319
-				switch($path)
319
+				switch ($path)
320 320
 				{
321 321
 					case '..':
322 322
 						$path = egw_vfs::dirname($content['nm']['path']);
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
 						$path = static::get_home_dir();
326 326
 						break;
327 327
 				}
328
-				if ($path[0] == '/' && egw_vfs::stat($path,true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path,egw_vfs::READABLE))
328
+				if ($path[0] == '/' && egw_vfs::stat($path, true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path, egw_vfs::READABLE))
329 329
 				{
330 330
 					$content['nm']['path'] = $path;
331 331
 				}
332 332
 				else
333 333
 				{
334
-					$msg .= lang('The requested path %1 is not available.',egw_vfs::decodePath($path));
334
+					$msg .= lang('The requested path %1 is not available.', egw_vfs::decodePath($path));
335 335
 				}
336 336
 				// reset lettersearch as it confuses users (they think the dir is empty)
337 337
 				$content['nm']['searchletter'] = false;
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 		}
342 342
 		$view = static::get_view();
343 343
 
344
-		if (strpos($view,'::') !== false && version_compare(PHP_VERSION,'5.3.0','<'))
344
+		if (strpos($view, '::') !== false && version_compare(PHP_VERSION, '5.3.0', '<'))
345 345
 		{
346
-			$view = explode('::',$view);
346
+			$view = explode('::', $view);
347 347
 		}
348
-		call_user_func($view,$content,$msg);
348
+		call_user_func($view, $content, $msg);
349 349
 	}
350 350
 
351 351
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise
359 359
 	 * @return boolean true is root user given, false otherwise (including logout / empty $user)
360 360
 	 */
361
-	protected function sudo($user='',$password=null,&$is_setup=null)
361
+	protected function sudo($user = '', $password = null, &$is_setup = null)
362 362
 	{
363 363
 		if (!$user)
364 364
 		{
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 		else
368 368
 		{
369 369
 			// config user & password
370
-			$is_setup = egw_session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash'];
370
+			$is_setup = egw_session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash'];
371 371
 			// or vfs root user from setup >> configuration
372
-			$is_root = $is_setup ||	$GLOBALS['egw_info']['server']['vfs_root_user'] &&
373
-				in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) &&
372
+			$is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] &&
373
+				in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) &&
374 374
 				$GLOBALS['egw']->auth->authenticate($user, $password, 'text');
375 375
 		}
376 376
 		//echo "<p>".__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".egw_session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root)."</p>\n";
377
-		egw_session::appsession('is_setup','filemanager',$is_setup);
378
-		return egw_session::appsession('is_root','filemanager',egw_vfs::$is_root = $is_root);
377
+		egw_session::appsession('is_setup', 'filemanager', $is_setup);
378
+		return egw_session::appsession('is_root', 'filemanager', egw_vfs::$is_root = $is_root);
379 379
 	}
380 380
 
381 381
 	/**
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 * @param array $content
385 385
 	 * @param string $msg
386 386
 	 */
387
-	function listview(array $content=null,$msg=null)
387
+	function listview(array $content = null, $msg = null)
388 388
 	{
389 389
 		$tpl = new etemplate_new('filemanager.index');
390 390
 
391
-		if($msg) egw_framework::message($msg);
391
+		if ($msg) egw_framework::message($msg);
392 392
 
393 393
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
394 394
 		{
395 395
 			if ($content['nm']['action'])
396 396
 			{
397
-				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
398
-				if($msg) egw_framework::message($msg);
397
+				$msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
398
+				if ($msg) egw_framework::message($msg);
399 399
 
400 400
 				// clean up after action
401 401
 				unset($content['nm']['selected']);
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
407 407
 				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
408 408
 			}
409
-			elseif($content['nm']['rows']['delete'])
409
+			elseif ($content['nm']['rows']['delete'])
410 410
 			{
411
-				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
412
-				if($msg) egw_framework::message($msg);
411
+				$msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']);
412
+				if ($msg) egw_framework::message($msg);
413 413
 
414 414
 				// clean up after action
415 415
 				unset($content['nm']['rows']['delete']);
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
422 422
 			}
423 423
 			unset($content['nm']['rows']);
424
-			egw_session::appsession('index','filemanager',$content['nm']);
424
+			egw_session::appsession('index', 'filemanager', $content['nm']);
425 425
 		}
426 426
 
427 427
 		// be tolerant with (in previous versions) not correct urlencoded pathes
428
-		if ($content['nm']['path'][0] == '/' && !egw_vfs::stat($content['nm']['path'],true) && egw_vfs::stat(urldecode($content['nm']['path'])))
428
+		if ($content['nm']['path'][0] == '/' && !egw_vfs::stat($content['nm']['path'], true) && egw_vfs::stat(urldecode($content['nm']['path'])))
429 429
 		{
430 430
 			$content['nm']['path'] = urldecode($content['nm']['path']);
431 431
 		}
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 				list($button) = each($content['button']);
437 437
 				unset($content['button']);
438 438
 			}
439
-			switch($button)
439
+			switch ($button)
440 440
 			{
441 441
 				case 'upload':
442 442
 					if (!$content['upload'])
443 443
 					{
444
-						egw_framework::message(lang('You need to select some files first!'),'error');
444
+						egw_framework::message(lang('You need to select some files first!'), 'error');
445 445
 						break;
446 446
 					}
447 447
 					$upload_success = $upload_failure = array();
448
-					foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
448
+					foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
449 449
 					{
450 450
 						// encode chars which special meaning in url/vfs (some like / get removed!)
451
-						$to = egw_vfs::concat($content['nm']['path'],egw_vfs::encodePathComponent($upload['name']));
451
+						$to = egw_vfs::concat($content['nm']['path'], egw_vfs::encodePathComponent($upload['name']));
452 452
 						if ($upload &&
453 453
 							(egw_vfs::is_writable($content['nm']['path']) || egw_vfs::is_writable($to)) &&
454
-							copy($upload['tmp_name'],egw_vfs::PREFIX.$to))
454
+							copy($upload['tmp_name'], egw_vfs::PREFIX.$to))
455 455
 						{
456 456
 							$upload_success[] = $upload['name'];
457 457
 						}
@@ -463,12 +463,11 @@  discard block
 block discarded – undo
463 463
 					$content['nm']['msg'] = '';
464 464
 					if ($upload_success)
465 465
 					{
466
-						egw_framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
467
-							lang('%1 successful uploaded.',implode(', ',$upload_success)));
466
+						egw_framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success)));
468 467
 					}
469 468
 					if ($upload_failure)
470 469
 					{
471
-						egw_framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error');
470
+						egw_framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error');
472 471
 					}
473 472
 					break;
474 473
 			}
@@ -489,17 +488,17 @@  discard block
 block discarded – undo
489 488
 			$tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv');
490 489
 		}
491 490
 		// Set view button to match current settings
492
-		if($content['nm']['view'] == 'tile')
491
+		if ($content['nm']['view'] == 'tile')
493 492
 		{
494
-			$tpl->setElementAttribute('nm[buttons][button][change_view]','label',lang('List view'));
495
-			$tpl->setElementAttribute('nm[buttons][button][change_view]','image','list_row');
493
+			$tpl->setElementAttribute('nm[buttons][button][change_view]', 'label', lang('List view'));
494
+			$tpl->setElementAttribute('nm[buttons][button][change_view]', 'image', 'list_row');
496 495
 
497 496
 		}
498 497
 		// if initial load is done via GET request (idots template or share.php)
499 498
 		// get_rows cant call app.filemanager.set_readonly, so we need to do that here
500 499
 		$content['initial_path_readonly'] = !egw_vfs::is_writable($content['nm']['path']);
501 500
 
502
-		$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
501
+		$tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm']));
503 502
 	}
504 503
 
505 504
 	/**
@@ -535,7 +534,7 @@  discard block
 block discarded – undo
535 534
 	 * @param int &$files=null on return number of files deleted
536 535
 	 * @return string success or failure message displayed to the user
537 536
 	 */
538
-	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
537
+	static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null)
539 538
 	{
540 539
 		if (!count($selected))
541 540
 		{
@@ -543,20 +542,20 @@  discard block
 block discarded – undo
543 542
 		}
544 543
 		$errs = $dirs = $files = 0;
545 544
 
546
-		switch($action)
545
+		switch ($action)
547 546
 		{
548 547
 
549 548
 			case 'delete':
550
-				return static::do_delete($selected,$errs,$files,$dirs);
549
+				return static::do_delete($selected, $errs, $files, $dirs);
551 550
 
552 551
 			case 'mail':
553 552
 			case 'copy':
554
-				foreach($selected as $path)
553
+				foreach ($selected as $path)
555 554
 				{
556 555
 					if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
557 556
 					{
558 557
 						// Support for dropping mail in filemanager - Pass mail back to mail app
559
-						if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
558
+						if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
560 559
 						{
561 560
 							++$files;
562 561
 						}
@@ -567,8 +566,8 @@  discard block
 block discarded – undo
567 566
 					}
568 567
 					elseif (!egw_vfs::is_dir($path))
569 568
 					{
570
-						$to = egw_vfs::concat($dir,egw_vfs::basename($path));
571
-						if ($path != $to && egw_vfs::copy($path,$to))
569
+						$to = egw_vfs::concat($dir, egw_vfs::basename($path));
570
+						if ($path != $to && egw_vfs::copy($path, $to))
572 571
 						{
573 572
 							++$files;
574 573
 						}
@@ -580,19 +579,19 @@  discard block
 block discarded – undo
580 579
 					else
581 580
 					{
582 581
 						$len = strlen(dirname($path));
583
-						foreach(egw_vfs::find($path) as $p)
582
+						foreach (egw_vfs::find($path) as $p)
584 583
 						{
585
-							$to = $dir.substr($p,$len);
584
+							$to = $dir.substr($p, $len);
586 585
 							if ($to == $p)	// cant copy into itself!
587 586
 							{
588 587
 								++$errs;
589 588
 								continue;
590 589
 							}
591
-							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
590
+							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE))
592 591
 							{
593 592
 								++$dirs;
594 593
 							}
595
-							elseif(!$is_dir && egw_vfs::copy($p,$to))
594
+							elseif (!$is_dir && egw_vfs::copy($p, $to))
596 595
 							{
597 596
 								++$files;
598 597
 							}
@@ -605,15 +604,15 @@  discard block
 block discarded – undo
605 604
 				}
606 605
 				if ($errs)
607 606
 				{
608
-					return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files);
607
+					return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files);
609 608
 				}
610
-				return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
609
+				return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files);
611 610
 
612 611
 			case 'move':
613
-				foreach($selected as $path)
612
+				foreach ($selected as $path)
614 613
 				{
615
-					$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir,egw_vfs::basename($path)) : $dir;
616
-					if ($path != $to && egw_vfs::rename($path,$to))
614
+					$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir, egw_vfs::basename($path)) : $dir;
615
+					if ($path != $to && egw_vfs::rename($path, $to))
617 616
 					{
618 617
 						++$files;
619 618
 					}
@@ -624,17 +623,17 @@  discard block
 block discarded – undo
624 623
 				}
625 624
 				if ($errs)
626 625
 				{
627
-					return lang('%1 errors moving (%2 files moved)!',$errs,$files);
626
+					return lang('%1 errors moving (%2 files moved)!', $errs, $files);
628 627
 				}
629
-				return lang('%1 files moved.',$files);
628
+				return lang('%1 files moved.', $files);
630 629
 
631 630
 			case 'symlink':	// symlink given files to $dir
632
-				foreach((array)$selected as $target)
631
+				foreach ((array)$selected as $target)
633 632
 				{
634 633
 					$link = egw_vfs::concat($dir, egw_vfs::basename($target));
635
-					if (!egw_vfs::stat($dir) || ($ok = egw_vfs::mkdir($dir,0,true)))
634
+					if (!egw_vfs::stat($dir) || ($ok = egw_vfs::mkdir($dir, 0, true)))
636 635
 					{
637
-						if(!$ok)
636
+						if (!$ok)
638 637
 						{
639 638
 							$errs++;
640 639
 							continue;
@@ -656,15 +655,14 @@  discard block
 block discarded – undo
656 655
 				}
657 656
 				if (count((array)$selected) == 1)
658 657
 				{
659
-					return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) :
660
-						lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
658
+					return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) : lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
661 659
 				}
662 660
 				$ret = lang('%1 elements linked.', $files);
663 661
 				if ($errs)
664 662
 				{
665
-					$ret = lang('%1 errors linking (%2)!',$errs, $ret);
663
+					$ret = lang('%1 errors linking (%2)!', $errs, $ret);
666 664
 				}
667
-				return $ret;//." egw_vfs::symlink('$target', '$link')";
665
+				return $ret; //." egw_vfs::symlink('$target', '$link')";
668 666
 
669 667
 			case 'createdir':
670 668
 				$dst = egw_vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
@@ -680,13 +678,13 @@  discard block
 block discarded – undo
680 678
 
681 679
 			default:
682 680
 				list($action, $settings) = explode('_', $action, 2);
683
-				switch($action)
681
+				switch ($action)
684 682
 				{
685 683
 					case 'document':
686 684
 						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
687 685
 						$document_merge = new filemanager_merge(egw_vfs::decodePath($dir));
688 686
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
689
-						if($msg) return $msg;
687
+						if ($msg) return $msg;
690 688
 						$errs = count($selected);
691 689
 						return false;
692 690
 				}
@@ -703,12 +701,12 @@  discard block
 block discarded – undo
703 701
 	 * @param int &$files=null on return number of files deleted
704 702
 	 * @return string
705 703
 	 */
706
-	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
704
+	public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null)
707 705
 	{
708 706
 		$dirs = $files = $errs = 0;
709 707
 		// we first delete all selected links (and files)
710 708
 		// feeding the links to dirs to egw_vfs::find() deletes the content of the dirs, not just the link!
711
-		foreach($selected as $key => $path)
709
+		foreach ($selected as $key => $path)
712 710
 		{
713 711
 			if (!egw_vfs::is_dir($path) || egw_vfs::is_link($path))
714 712
 			{
@@ -726,21 +724,21 @@  discard block
 block discarded – undo
726 724
 		if ($selected)	// somethings left to delete
727 725
 		{
728 726
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
729
-			foreach((array)$selected as $path)
727
+			foreach ((array)$selected as $path)
730 728
 			{
731
-				if (preg_match('/^\/?(home|apps|)\/*$/',$path))
729
+				if (preg_match('/^\/?(home|apps|)\/*$/', $path))
732 730
 				{
733 731
 					$errs++;
734
-					return lang("Cautiously rejecting to remove folder '%1'!",egw_vfs::decodePath($path));
732
+					return lang("Cautiously rejecting to remove folder '%1'!", egw_vfs::decodePath($path));
735 733
 				}
736 734
 			}
737 735
 			// now we use find to loop through all files and dirs: (selected only contains dirs now)
738 736
 			// - depth=true to get first the files and then the dir containing it
739 737
 			// - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs
740 738
 			// - show-deleted=false to not (finally) deleted versioned files
741
-			foreach(egw_vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path)
739
+			foreach (egw_vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path)
742 740
 			{
743
-				if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path,0))
741
+				if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path, 0))
744 742
 				{
745 743
 					++$dirs;
746 744
 				}
@@ -756,13 +754,13 @@  discard block
 block discarded – undo
756 754
 		}
757 755
 		if ($errs)
758 756
 		{
759
-			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files);
757
+			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files);
760 758
 		}
761 759
 		if ($dirs)
762 760
 		{
763
-			return lang('%1 directories and %2 files deleted.',$dirs,$files);
761
+			return lang('%1 directories and %2 files deleted.', $dirs, $files);
764 762
 		}
765
-		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files);
763
+		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files);
766 764
 	}
767 765
 
768 766
 	/**
@@ -774,44 +772,44 @@  discard block
 block discarded – undo
774 772
 	function get_rows(&$query, &$rows)
775 773
 	{
776 774
 		// show projectmanager sidebox for projectmanager path
777
-		if (substr($query['path'],0,20) == '/apps/projectmanager' && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
775
+		if (substr($query['path'], 0, 20) == '/apps/projectmanager' && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
778 776
 		{
779 777
 			$GLOBALS['egw_info']['flags']['currentapp'] = 'projectmanager';
780 778
 		}
781 779
 		// do NOT store query, if hierarchical data / children are requested
782 780
 		if (!$query['csv_export'])
783 781
 		{
784
-			egw_session::appsession('index','filemanager',$query);
782
+			egw_session::appsession('index', 'filemanager', $query);
785 783
 		}
786
-		if(!$query['path']) $query['path'] = static::get_home_dir();
784
+		if (!$query['path']) $query['path'] = static::get_home_dir();
787 785
 
788 786
 		// Change template to match selected view
789
-		if($query['view'])
787
+		if ($query['view'])
790 788
 		{
791 789
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile');
792 790
 
793 791
 			// Store as preference but only for index, not home
794
-			if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
792
+			if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
795 793
 			{
796
-				$GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']);
794
+				$GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']);
797 795
 				$GLOBALS['egw']->preferences->save_repository();
798 796
 			}
799 797
 		}
800 798
 		// be tolerant with (in previous versions) not correct urlencoded pathes
801
-		if (!egw_vfs::stat($query['path'],true) && egw_vfs::stat(urldecode($query['path'])))
799
+		if (!egw_vfs::stat($query['path'], true) && egw_vfs::stat(urldecode($query['path'])))
802 800
 		{
803 801
 			$query['path'] = urldecode($query['path']);
804 802
 		}
805
-		if (!egw_vfs::stat($query['path'],true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'],egw_vfs::READABLE))
803
+		if (!egw_vfs::stat($query['path'], true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'], egw_vfs::READABLE))
806 804
 		{
807 805
 			// only redirect, if it would be to some other location, gives redirect-loop otherwise
808 806
 			if ($query['path'] != ($path = static::get_home_dir()))
809 807
 			{
810 808
 				// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
811 809
 				// an appropriate message
812
-				egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
810
+				egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index',
813 811
 					'path' => $path,
814
-					'msg' => lang('The requested path %1 is not available.',egw_vfs::decodePath($query['path'])),
812
+					'msg' => lang('The requested path %1 is not available.', egw_vfs::decodePath($query['path'])),
815 813
 					'ajax' => 'true'
816 814
 				));
817 815
 			}
@@ -819,35 +817,35 @@  discard block
 block discarded – undo
819 817
 			return 0;
820 818
 		}
821 819
 		$rows = $dir_is_writable = array();
822
-		if($query['searchletter'] && !empty($query['search']))
820
+		if ($query['searchletter'] && !empty($query['search']))
823 821
 		{
824
-			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
822
+			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
825 823
 			if ($query['searchletter'] == strtolower($query['search'][0]))
826 824
 			{
827
-				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'.
828
-					str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i';
825
+				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'.
826
+					str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i';
829 827
 			}
830 828
 		}
831 829
 		elseif ($query['searchletter'])
832 830
 		{
833 831
 			$namefilter = '/^'.$query['searchletter'].'/i';
834 832
 		}
835
-		elseif(!empty($query['search']))
833
+		elseif (!empty($query['search']))
836 834
 		{
837
-			$namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
835
+			$namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
838 836
 		}
839 837
 
840 838
 		// Re-map so 'No filters' favorite ('') is depth 1
841 839
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
842 840
 
843 841
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
844
-		if($filter == 5) $maxdepth = 2;
842
+		if ($filter == 5) $maxdepth = 2;
845 843
 		$n = 0;
846 844
 		$vfs_options = array(
847 845
 			'mindepth' => 1,
848 846
 			'maxdepth' => $maxdepth,
849 847
 			'dirsontop' => $filter <= 1,
850
-			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'),
848
+			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'),
851 849
 			'order' => $query['order'], 'sort' => $query['sort'],
852 850
 			'limit' => (int)$query['num_rows'].','.(int)$query['start'],
853 851
 			'need_mime' => true,
@@ -855,11 +853,11 @@  discard block
 block discarded – undo
855 853
 			'hidden' => $filter == 3,
856 854
 			'follow' => $filter == 5,
857 855
 		);
858
-		if($query['col_filter']['mime'])
856
+		if ($query['col_filter']['mime'])
859 857
 		{
860 858
 			$vfs_options['mime'] = $query['col_filter']['mime'];
861 859
 		}
862
-		foreach(egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row)
860
+		foreach (egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row)
863 861
 		{
864 862
 			//echo $path; _debug_array($row);
865 863
 
@@ -873,32 +871,32 @@  discard block
 block discarded – undo
873 871
 				$row['class'] = 'isDir';
874 872
 			}
875 873
 			$row['download_url'] = egw_vfs::download_url($path);
876
-			$row['gid'] = -abs($row['gid']);	// gid are positive, but we use negagive account_id for groups internal
874
+			$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
877 875
 
878 876
 			$rows[++$n] = $row;
879 877
 			$path2n[$path] = $n;
880 878
 		}
881 879
 		// query comments and cf's for the displayed rows
882
-		$cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
880
+		$cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
883 881
 
884 882
 		// Always include comment in tiles
885
-		if($query['view'] == 'tile')
883
+		if ($query['view'] == 'tile')
886 884
 		{
887 885
 			$cols_to_show[] = 'comment';
888 886
 		}
889
-		$all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#';
890
-		if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) &&
887
+		$all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#';
888
+		if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) &&
891 889
 			($path2props = egw_vfs::propfind(array_keys($path2n))))
892 890
 		{
893
-			foreach($path2props as $path => $props)
891
+			foreach ($path2props as $path => $props)
894 892
 			{
895
-				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
896
-				$row =& $rows[$path2n[$path]];
897
-				if ( !is_array($props) ) continue;
898
-				foreach($props as $prop)
893
+				unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2
894
+				$row = & $rows[$path2n[$path]];
895
+				if (!is_array($props)) continue;
896
+				foreach ($props as $prop)
899 897
 				{
900
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
901
-					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
898
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue;
899
+					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...';
902 900
 				}
903 901
 			}
904 902
 		}
@@ -910,7 +908,7 @@  discard block
 block discarded – undo
910 908
 		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager')
911 909
 		{
912 910
 			// we need our app.css file
913
-			if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
911
+			if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
914 912
 			{
915 913
 				$css_file = '/filemanager/templates/default/app.css';
916 914
 			}
@@ -926,7 +924,7 @@  discard block
 block discarded – undo
926 924
 	 * @param array $content
927 925
 	 * @param string $msg
928 926
 	 */
929
-	function file(array $content=null,$msg='')
927
+	function file(array $content = null, $msg = '')
930 928
 	{
931 929
 		$tpl = new etemplate_new('filemanager.file');
932 930
 
@@ -936,9 +934,9 @@  discard block
 block discarded – undo
936 934
 			{
937 935
 				$msg .= $_GET['msg'];
938 936
 			}
939
-			if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) ||	// ?, # need to stay encoded!
937
+			if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded!
940 938
 				// actions enclose pathes containing comma with "
941
-				($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) ||
939
+				($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) ||
942 940
 				!($stat = egw_vfs::lstat($path)))
943 941
 			{
944 942
 				$msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat);
@@ -951,10 +949,10 @@  discard block
 block discarded – undo
951 949
 				$content['path'] = $path;
952 950
 				$content['hsize'] = egw_vfs::hsize($stat['size']);
953 951
 				$content['mime'] = egw_vfs::mime_content_type($path);
954
-				$content['gid'] *= -1;	// our widgets use negative gid's
952
+				$content['gid'] *= -1; // our widgets use negative gid's
955 953
 				if (($props = egw_vfs::propfind($path)))
956 954
 				{
957
-					foreach($props as $prop)
955
+					foreach ($props as $prop)
958 956
 					{
959 957
 						$content[$prop['name']] = $prop['val'];
960 958
 					}
@@ -967,9 +965,9 @@  discard block
 block discarded – undo
967 965
 			$content['tabs'] = $_GET['tabs'];
968 966
 			if (!($content['is_dir'] = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)))
969 967
 			{
970
-				$content['perms']['executable'] = (int)!!($content['mode'] & 0111);
968
+				$content['perms']['executable'] = (int)!!($content['mode']&0111);
971 969
 				$mask = 6;
972
-				if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000)
970
+				if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000)
973 971
 				{
974 972
 					$content['text_content'] = file_get_contents(egw_vfs::PREFIX.$path);
975 973
 				}
@@ -979,19 +977,19 @@  discard block
 block discarded – undo
979 977
 				//currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201);
980 978
 				$mask = 7;
981 979
 			}
982
-			foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift)
980
+			foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift)
983 981
 			{
984
-				$content['perms'][$name] = ($content['mode'] >> $shift) & $mask;
982
+				$content['perms'][$name] = ($content['mode'] >> $shift)&$mask;
985 983
 			}
986
-			$content['is_owner'] = egw_vfs::has_owner_rights($path,$content);
984
+			$content['is_owner'] = egw_vfs::has_owner_rights($path, $content);
987 985
 		}
988 986
 		else
989 987
 		{
990 988
 			//_debug_array($content);
991
-			$path =& $content['path'];
989
+			$path = & $content['path'];
992 990
 
993 991
 			list($button) = @each($content['button']); unset($content['button']);
994
-			if(!$button && $content['sudo'])
992
+			if (!$button && $content['sudo'])
995 993
 			{
996 994
 				// Button to stop sudo is not in button namespace
997 995
 				$button = 'sudo';
@@ -1000,45 +998,45 @@  discard block
 block discarded – undo
1000 998
 			// need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field
1001 999
 			if ($button == 'sudo' && egw_vfs::$is_root || $button == 'setup' && $content['sudo']['user'])
1002 1000
 			{
1003
-				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ?
1001
+				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ?
1004 1002
 					lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ?
1005 1003
 					lang('Wrong username or password!') : lang('Root access stopped.'));
1006 1004
 				unset($content['sudo']);
1007 1005
 				$content['is_owner'] = egw_vfs::has_owner_rights($path);
1008 1006
 			}
1009
-			if (in_array($button,array('save','apply')))
1007
+			if (in_array($button, array('save', 'apply')))
1010 1008
 			{
1011 1009
 				$props = array();
1012 1010
 				$perm_changed = $perm_failed = 0;
1013
-				foreach($content['old'] as $name => $old_value)
1011
+				foreach ($content['old'] as $name => $old_value)
1014 1012
 				{
1015 1013
 					if (isset($content[$name]) && ($old_value != $content[$name] ||
1016 1014
 						// do not check for modification, if modify_subs is checked!
1017
-						$content['modify_subs'] && in_array($name,array('uid','gid','perms'))) &&
1015
+						$content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) &&
1018 1016
 						($name != 'uid' || egw_vfs::$is_root))
1019 1017
 					{
1020 1018
 						if ($name == 'name')
1021 1019
 						{
1022
-							$to = egw_vfs::concat(egw_vfs::dirname($path),$content['name']);
1020
+							$to = egw_vfs::concat(egw_vfs::dirname($path), $content['name']);
1023 1021
 							if (file_exists(egw_vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to)
1024 1022
 							{
1025
-								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1026
-									lang('To overwrite the existing file store again.',lang($button)));
1023
+								$tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'.
1024
+									lang('To overwrite the existing file store again.', lang($button)));
1027 1025
 								$content['confirm_overwrite'] = $to;
1028 1026
 								if ($button == 'save') $button = 'apply';
1029 1027
 								continue;
1030 1028
 							}
1031
-							if (egw_vfs::rename($path,$to))
1029
+							if (egw_vfs::rename($path, $to))
1032 1030
 							{
1033
-								$msg .= lang('Renamed %1 to %2.',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
1031
+								$msg .= lang('Renamed %1 to %2.', egw_vfs::decodePath(basename($path)), egw_vfs::decodePath(basename($to))).' ';
1034 1032
 								$content['old']['name'] = $content[$name];
1035 1033
 								$path = $to;
1036
-								$content['mime'] = mime_magic::filename2mime($path);	// recheck mime type
1037
-								$refresh_path = egw_vfs::dirname($path);	// for renames, we have to refresh the parent
1034
+								$content['mime'] = mime_magic::filename2mime($path); // recheck mime type
1035
+								$refresh_path = egw_vfs::dirname($path); // for renames, we have to refresh the parent
1038 1036
 							}
1039 1037
 							else
1040 1038
 							{
1041
-								$msg .= lang('Rename of %1 to %2 failed!',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
1039
+								$msg .= lang('Rename of %1 to %2 failed!', egw_vfs::decodePath(basename($path)), egw_vfs::decodePath(basename($to))).' ';
1042 1040
 								if (egw_vfs::deny_script($to))
1043 1041
 								{
1044 1042
 									$msg .= lang('You are NOT allowed to upload a script!').' ';
@@ -1058,7 +1056,7 @@  discard block
 block discarded – undo
1058 1056
 									'val'	=> (!empty($content[$name]) ? $content[$name] : null),
1059 1057
 								),
1060 1058
 							);
1061
-							if (egw_vfs::proppatch($path,$mergeprop))
1059
+							if (egw_vfs::proppatch($path, $mergeprop))
1062 1060
 							{
1063 1061
 								$content['old'][$name] = $content[$name];
1064 1062
 								$msg .= lang('Setting for document merge saved.');
@@ -1070,22 +1068,22 @@  discard block
 block discarded – undo
1070 1068
 						}
1071 1069
 						else
1072 1070
 						{
1073
-							static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
1074
-							$cmd = array('egw_vfs',$name2cmd[$name]);
1071
+							static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod');
1072
+							$cmd = array('egw_vfs', $name2cmd[$name]);
1075 1073
 							$value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name];
1076 1074
 							if ($content['modify_subs'])
1077 1075
 							{
1078 1076
 								if ($name == 'perms')
1079 1077
 								{
1080
-									$changed = egw_vfs::find($path,array('type'=>'d'),$cmd,array($value));
1081
-									$changed += egw_vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666));	// no execute for files
1078
+									$changed = egw_vfs::find($path, array('type'=>'d'), $cmd, array($value));
1079
+									$changed += egw_vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files
1082 1080
 								}
1083 1081
 								else
1084 1082
 								{
1085
-									$changed = egw_vfs::find($path,null,$cmd,array($value));
1083
+									$changed = egw_vfs::find($path, null, $cmd, array($value));
1086 1084
 								}
1087 1085
 								$ok = $failed = 0;
1088
-								foreach($changed as &$r)
1086
+								foreach ($changed as &$r)
1089 1087
 								{
1090 1088
 									if ($r)
1091 1089
 									{
@@ -1098,32 +1096,32 @@  discard block
 block discarded – undo
1098 1096
 								}
1099 1097
 								if ($ok && !$failed)
1100 1098
 								{
1101
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1099
+									if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren'));
1102 1100
 									$content['old'][$name] = $content[$name];
1103 1101
 								}
1104
-								elseif($failed)
1102
+								elseif ($failed)
1105 1103
 								{
1106
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1107
-										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1104
+									if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren').
1105
+										($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : ''));
1108 1106
 								}
1109 1107
 							}
1110
-							elseif (call_user_func_array($cmd,array($path,$value)))
1108
+							elseif (call_user_func_array($cmd, array($path, $value)))
1111 1109
 							{
1112
-								$msg .= lang('Permissions of %1 changed.',$path);
1110
+								$msg .= lang('Permissions of %1 changed.', $path);
1113 1111
 								$content['old'][$name] = $content[$name];
1114 1112
 							}
1115 1113
 							else
1116 1114
 							{
1117
-								$msg .= lang('Failed to change permissions of %1!',$path);
1115
+								$msg .= lang('Failed to change permissions of %1!', $path);
1118 1116
 							}
1119 1117
 						}
1120 1118
 					}
1121 1119
 				}
1122 1120
 				if ($props)
1123 1121
 				{
1124
-					if (egw_vfs::proppatch($path,$props))
1122
+					if (egw_vfs::proppatch($path, $props))
1125 1123
 					{
1126
-						foreach($props as $prop)
1124
+						foreach ($props as $prop)
1127 1125
 						{
1128 1126
 							$content['old'][$prop['name']] = $prop['val'];
1129 1127
 						}
@@ -1140,8 +1138,8 @@  discard block
 block discarded – undo
1140 1138
 				if ($content['eacl']['delete'])
1141 1139
 				{
1142 1140
 					list($ino_owner) = each($content['eacl']['delete']);
1143
-					list(, $owner) = explode('-',$ino_owner,2);	// $owner is a group and starts with a minus!
1144
-					$msg .= egw_vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1141
+					list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus!
1142
+					$msg .= egw_vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1145 1143
 				}
1146 1144
 				elseif ($button == 'eacl')
1147 1145
 				{
@@ -1151,7 +1149,7 @@  discard block
 block discarded – undo
1151 1149
 					}
1152 1150
 					else
1153 1151
 					{
1154
-						$msg .= egw_vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ?
1152
+						$msg .= egw_vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ?
1155 1153
 							lang('ACL added.') : lang('Error adding the ACL!');
1156 1154
 					}
1157 1155
 				}
@@ -1161,7 +1159,7 @@  discard block
 block discarded – undo
1161 1159
 		}
1162 1160
 		if ($content['is_link'] && !egw_vfs::stat($path))
1163 1161
 		{
1164
-			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']);
1162
+			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']);
1165 1163
 		}
1166 1164
 		$content['link'] = egw::link(egw_vfs::download_url($path));
1167 1165
 		$content['icon'] = egw_vfs::mime_icon($content['mime']);
@@ -1170,10 +1168,10 @@  discard block
 block discarded – undo
1170 1168
 		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1171 1169
 		// only owner can change group & perms
1172 1170
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1173
-			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1171
+			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1174 1172
 		{
1175 1173
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1176
-			foreach($content['perms'] as $name => $value)
1174
+			foreach ($content['perms'] as $name => $value)
1177 1175
 			{
1178 1176
 				$readonlys['perms['.$name.']'] = true;
1179 1177
 			}
@@ -1191,37 +1189,37 @@  discard block
 block discarded – undo
1191 1189
 		}
1192 1190
 		elseif (!egw_vfs::is_writable($path))
1193 1191
 		{
1194
-			foreach($cfs as $name => $data)
1192
+			foreach ($cfs as $name => $data)
1195 1193
 			{
1196 1194
 				$readonlys['#'.$name] = true;
1197 1195
 			}
1198 1196
 		}
1199
-		$readonlys['tabs']['filemanager.file.eacl'] = true;	// eacl off by default
1197
+		$readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default
1200 1198
 		if ($content['is_dir'])
1201 1199
 		{
1202
-			$readonlys['tabs']['filemanager.file.preview'] = true;	// no preview tab for dirs
1203
-			$sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1200
+			$readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs
1201
+			$sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1204 1202
 				7 => lang('Display and modification of content'),
1205 1203
 				5 => lang('Display of content'),
1206 1204
 				0 => lang('No access'),
1207 1205
 			);
1208
-			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1206
+			if (($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1209 1207
 			{
1210
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1211
-				foreach($content['eacl'] as &$eacl)
1208
+				unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again
1209
+				foreach ($content['eacl'] as &$eacl)
1212 1210
 				{
1213
-					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
1211
+					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'], PHP_URL_PATH), '/');
1214 1212
 					$readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] ||
1215 1213
 						$eacl['path'] != $content['path'] || !$content['is_owner'];
1216 1214
 				}
1217
-				array_unshift($content['eacl'],false);	// make the keys start with 1, not 0
1215
+				array_unshift($content['eacl'], false); // make the keys start with 1, not 0
1218 1216
 				$content['eacl']['owner'] = 0;
1219 1217
 				$content['eacl']['rights'] = 5;
1220 1218
 			}
1221 1219
 		}
1222 1220
 		else
1223 1221
 		{
1224
-			$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1222
+			$sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1225 1223
 				6 => lang('Read & write access'),
1226 1224
 				4 => lang('Read access only'),
1227 1225
 				0 => lang('No access'),
@@ -1231,11 +1229,11 @@  discard block
 block discarded – undo
1231 1229
 		// mergeapp
1232 1230
 		$content['mergeapp'] = static::get_mergeapp($path, 'self');
1233 1231
 		$content['mergeapp_parent'] = static::get_mergeapp($path, 'parents');
1234
-		if(!empty($content['mergeapp']))
1232
+		if (!empty($content['mergeapp']))
1235 1233
 		{
1236 1234
 			$content['mergeapp_effective'] = $content['mergeapp'];
1237 1235
 		}
1238
-		elseif(!empty($content['mergeapp_parent']))
1236
+		elseif (!empty($content['mergeapp_parent']))
1239 1237
 		{
1240 1238
 			$content['mergeapp_effective'] = $content['mergeapp_parent'];
1241 1239
 		}
@@ -1247,7 +1245,7 @@  discard block
 block discarded – undo
1247 1245
 		$mergeapp_list = egw_link::app_list('merge');
1248 1246
 		unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list
1249 1247
 		$mergeapp_empty = !empty($content['mergeapp_parent'])
1250
-			? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
1248
+			? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : '';
1251 1249
 		$sel_options['mergeapp'] = array(''	=> $mergeapp_empty);
1252 1250
 		$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
1253 1251
 		// mergeapp other gui options
@@ -1264,7 +1262,7 @@  discard block
 block discarded – undo
1264 1262
 				'comment' => (string)$content['comment'],
1265 1263
 				'mergeapp' => $content['mergeapp']
1266 1264
 			);
1267
-			if ($cfs) foreach($cfs as $name => $data)
1265
+			if ($cfs) foreach ($cfs as $name => $data)
1268 1266
 			{
1269 1267
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1270 1268
 			}
@@ -1272,26 +1270,26 @@  discard block
 block discarded – undo
1272 1270
 		if (egw_vfs::$is_root)
1273 1271
 		{
1274 1272
 			$tpl->setElementAttribute('sudouser', 'label', 'Logout');
1275
-			$tpl->setElementAttribute('sudouser', 'help','Log out as superuser');
1273
+			$tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser');
1276 1274
 			// Need a more complex submit because button type is buttononly, which doesn't submit
1277
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")');
1275
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")');
1278 1276
 
1279 1277
 		}
1280 1278
 		elseif ($button == 'sudo')
1281 1279
 		{
1282 1280
 			$tpl->setElementAttribute('sudouser', 'label', 'Superuser');
1283
-			$tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights');
1284
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")');
1281
+			$tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights');
1282
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")');
1285 1283
 		}
1286
-		if (($extra_tabs = egw_vfs::getExtraInfo($path,$content)))
1284
+		if (($extra_tabs = egw_vfs::getExtraInfo($path, $content)))
1287 1285
 		{
1288 1286
 			// add to existing tabs in template
1289 1287
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1290 1288
 
1291
-			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1289
+			$tabs = & $tpl->getElementAttribute('tabs', 'tabs');
1292 1290
 			if (true) $tabs = array();
1293 1291
 
1294
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1292
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1295 1293
 			{
1296 1294
 				$tabs[] = array(
1297 1295
 					'label' =>	$extra_tab['label'],
@@ -1314,7 +1312,7 @@  discard block
 block discarded – undo
1314 1312
 		egw_framework::window_focus();
1315 1313
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.egw_vfs::decodePath($path);
1316 1314
 
1317
-		$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
1315
+		$tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2);
1318 1316
 	}
1319 1317
 
1320 1318
 	/**
@@ -1325,10 +1323,10 @@  discard block
 block discarded – undo
1325 1323
 	 * @param string $dir=null current directory
1326 1324
 	 * @see static::action()
1327 1325
 	 */
1328
-	public static function ajax_action($action, $selected, $dir=null, $props=null)
1326
+	public static function ajax_action($action, $selected, $dir = null, $props = null)
1329 1327
 	{
1330 1328
 		// do we have root rights, need to run here too, as method is static and therefore does NOT run __construct
1331
-		if (egw_session::appsession('is_root','filemanager'))
1329
+		if (egw_session::appsession('is_root', 'filemanager'))
1332 1330
 		{
1333 1331
 			egw_vfs::$is_root = true;
1334 1332
 		}
@@ -1344,15 +1342,15 @@  discard block
 block discarded – undo
1344 1342
 
1345 1343
 		if (!isset($dir)) $dir = array_pop($selected);
1346 1344
 
1347
-		switch($action)
1345
+		switch ($action)
1348 1346
 		{
1349 1347
 			case 'upload':
1350 1348
 				$script_error = 0;
1351
-				foreach($selected as $tmp_name => &$data)
1349
+				foreach ($selected as $tmp_name => &$data)
1352 1350
 				{
1353 1351
 					$path = egw_vfs::concat($dir, egw_vfs::encodePathComponent($data['name']));
1354 1352
 
1355
-					if(egw_vfs::deny_script($path))
1353
+					if (egw_vfs::deny_script($path))
1356 1354
 					{
1357 1355
 						if (!isset($script_error))
1358 1356
 						{
@@ -1374,7 +1372,7 @@  discard block
 block discarded – undo
1374 1372
 					{
1375 1373
 						if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
1376 1374
 						{
1377
-							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
1375
+							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name);
1378 1376
 						}
1379 1377
 						else
1380 1378
 						{
@@ -1409,16 +1407,16 @@  discard block
 block discarded – undo
1409 1407
 			case 'link':
1410 1408
 				// First upload
1411 1409
 				$arr = static::ajax_action('upload', $selected, $dir, $props);
1412
-				$app_dir = egw_link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
1410
+				$app_dir = egw_link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true);
1413 1411
 
1414
-				foreach($arr['uploaded'] as $file)
1412
+				foreach ($arr['uploaded'] as $file)
1415 1413
 				{
1416
-					$target=egw_vfs::concat($dir,egw_vfs::encodePathComponent($file['name']));
1414
+					$target = egw_vfs::concat($dir, egw_vfs::encodePathComponent($file['name']));
1417 1415
 					if (egw_vfs::file_exists($target) && $app_dir)
1418 1416
 					{
1419 1417
 						if (!egw_vfs::file_exists($app_dir)) egw_vfs::mkdir($app_dir);
1420 1418
 						error_log("Symlinking $target to $app_dir");
1421
-						egw_vfs::symlink($target, egw_vfs::concat($app_dir,egw_vfs::encodePathComponent($file['name'])));
1419
+						egw_vfs::symlink($target, egw_vfs::concat($app_dir, egw_vfs::encodePathComponent($file['name'])));
1422 1420
 					}
1423 1421
 				}
1424 1422
 				// Must return to avoid adding to $response again
@@ -1440,7 +1438,7 @@  discard block
 block discarded – undo
1440 1438
 	 */
1441 1439
 	private function perms2mode(array $perms)
1442 1440
 	{
1443
-		$mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other'];
1441
+		$mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other'];
1444 1442
 		if ($mode['executable'])
1445 1443
 		{
1446 1444
 			$mode |= 0111;
Please login to merge, or discard this patch.
Braces   +138 added lines, -35 removed lines patch added patch discarded remove patch
@@ -79,7 +79,10 @@  discard block
 block discarded – undo
79 79
 			// search for plugins with additional filemanager views
80 80
 			foreach($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
81 81
 			{
82
-				if (is_array($views)) static::$views += $views;
82
+				if (is_array($views))
83
+				{
84
+					static::$views += $views;
85
+				}
83 86
 			}
84 87
 			static::$views_init = true;
85 88
 		}
@@ -302,7 +305,10 @@  discard block
 block discarded – undo
302 305
 			$content['nm']['home_dir'] = static::get_home_dir();
303 306
 			$content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view'];
304 307
 
305
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
308
+			if (isset($_GET['msg']))
309
+			{
310
+				$msg = $_GET['msg'];
311
+			}
306 312
 
307 313
 			// Blank favorite set via GET needs special handling for path
308 314
 			if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank')
@@ -336,7 +342,10 @@  discard block
 block discarded – undo
336 342
 				// reset lettersearch as it confuses users (they think the dir is empty)
337 343
 				$content['nm']['searchletter'] = false;
338 344
 				// switch recusive display off
339
-				if (!$content['nm']['filter']) $content['nm']['filter'] = '';
345
+				if (!$content['nm']['filter'])
346
+				{
347
+					$content['nm']['filter'] = '';
348
+				}
340 349
 			}
341 350
 		}
342 351
 		$view = static::get_view();
@@ -388,37 +397,70 @@  discard block
 block discarded – undo
388 397
 	{
389 398
 		$tpl = new etemplate_new('filemanager.index');
390 399
 
391
-		if($msg) egw_framework::message($msg);
400
+		if($msg)
401
+		{
402
+			egw_framework::message($msg);
403
+		}
392 404
 
393 405
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
394 406
 		{
395 407
 			if ($content['nm']['action'])
396 408
 			{
397 409
 				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
398
-				if($msg) egw_framework::message($msg);
410
+				if($msg)
411
+				{
412
+					egw_framework::message($msg);
413
+				}
399 414
 
400 415
 				// clean up after action
401 416
 				unset($content['nm']['selected']);
402 417
 				// reset any occasion where action may be stored, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
403
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
404
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
405
-				if (isset($content['nm_action'])) unset($content['nm_action']);
418
+				if (isset($content['nm']['action']))
419
+				{
420
+					unset($content['nm']['action']);
421
+				}
422
+				if (isset($content['nm']['nm_action']))
423
+				{
424
+					unset($content['nm']['nm_action']);
425
+				}
426
+				if (isset($content['nm_action']))
427
+				{
428
+					unset($content['nm_action']);
429
+				}
406 430
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
407
-				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
431
+				if (isset($content['nm']['rows']['delete']))
432
+				{
433
+					unset($content['nm']['rows']['delete']);
434
+				}
408 435
 			}
409 436
 			elseif($content['nm']['rows']['delete'])
410 437
 			{
411 438
 				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
412
-				if($msg) egw_framework::message($msg);
439
+				if($msg)
440
+				{
441
+					egw_framework::message($msg);
442
+				}
413 443
 
414 444
 				// clean up after action
415 445
 				unset($content['nm']['rows']['delete']);
416 446
 				// reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow
417 447
 				// we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
418
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
419
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
420
-				if (isset($content['nm_action'])) unset($content['nm_action']);
421
-				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
448
+				if (isset($content['nm']['action']))
449
+				{
450
+					unset($content['nm']['action']);
451
+				}
452
+				if (isset($content['nm']['nm_action']))
453
+				{
454
+					unset($content['nm']['nm_action']);
455
+				}
456
+				if (isset($content['nm_action']))
457
+				{
458
+					unset($content['nm_action']);
459
+				}
460
+				if (isset($content['nm']['selected']))
461
+				{
462
+					unset($content['nm']['selected']);
463
+				}
422 464
 			}
423 465
 			unset($content['nm']['rows']);
424 466
 			egw_session::appsession('index','filemanager',$content['nm']);
@@ -583,9 +625,12 @@  discard block
 block discarded – undo
583 625
 						foreach(egw_vfs::find($path) as $p)
584 626
 						{
585 627
 							$to = $dir.substr($p,$len);
586
-							if ($to == $p)	// cant copy into itself!
628
+							if ($to == $p)
629
+							{
630
+								// cant copy into itself!
587 631
 							{
588 632
 								++$errs;
633
+							}
589 634
 								continue;
590 635
 							}
591 636
 							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
@@ -640,7 +685,10 @@  discard block
 block discarded – undo
640 685
 							continue;
641 686
 						}
642 687
 					}
643
-					if ($target[0] != '/') $target = egw_vfs::concat($dir, $target);
688
+					if ($target[0] != '/')
689
+					{
690
+						$target = egw_vfs::concat($dir, $target);
691
+					}
644 692
 					if (!egw_vfs::stat($target))
645 693
 					{
646 694
 						return lang('Link target %1 not found!', egw_vfs::decodePath($target));
@@ -683,10 +731,16 @@  discard block
 block discarded – undo
683 731
 				switch($action)
684 732
 				{
685 733
 					case 'document':
686
-						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
734
+						if (!$settings)
735
+						{
736
+							$settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
737
+						}
687 738
 						$document_merge = new filemanager_merge(egw_vfs::decodePath($dir));
688 739
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
689
-						if($msg) return $msg;
740
+						if($msg)
741
+						{
742
+							return $msg;
743
+						}
690 744
 						$errs = count($selected);
691 745
 						return false;
692 746
 				}
@@ -723,7 +777,9 @@  discard block
 block discarded – undo
723 777
 				unset($selected[$key]);
724 778
 			}
725 779
 		}
726
-		if ($selected)	// somethings left to delete
780
+		if ($selected)
781
+		{
782
+			// somethings left to delete
727 783
 		{
728 784
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
729 785
 			foreach((array)$selected as $path)
@@ -731,6 +787,7 @@  discard block
 block discarded – undo
731 787
 				if (preg_match('/^\/?(home|apps|)\/*$/',$path))
732 788
 				{
733 789
 					$errs++;
790
+		}
734 791
 					return lang("Cautiously rejecting to remove folder '%1'!",egw_vfs::decodePath($path));
735 792
 				}
736 793
 			}
@@ -783,7 +840,10 @@  discard block
 block discarded – undo
783 840
 		{
784 841
 			egw_session::appsession('index','filemanager',$query);
785 842
 		}
786
-		if(!$query['path']) $query['path'] = static::get_home_dir();
843
+		if(!$query['path'])
844
+		{
845
+			$query['path'] = static::get_home_dir();
846
+		}
787 847
 
788 848
 		// Change template to match selected view
789 849
 		if($query['view'])
@@ -841,7 +901,10 @@  discard block
 block discarded – undo
841 901
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
842 902
 
843 903
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
844
-		if($filter == 5) $maxdepth = 2;
904
+		if($filter == 5)
905
+		{
906
+			$maxdepth = 2;
907
+		}
845 908
 		$n = 0;
846 909
 		$vfs_options = array(
847 910
 			'mindepth' => 1,
@@ -894,10 +957,16 @@  discard block
 block discarded – undo
894 957
 			{
895 958
 				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
896 959
 				$row =& $rows[$path2n[$path]];
897
-				if ( !is_array($props) ) continue;
960
+				if ( !is_array($props) )
961
+				{
962
+					continue;
963
+				}
898 964
 				foreach($props as $prop)
899 965
 				{
900
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
966
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show))
967
+					{
968
+						continue;
969
+					}
901 970
 					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
902 971
 				}
903 972
 			}
@@ -1025,7 +1094,10 @@  discard block
 block discarded – undo
1025 1094
 								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1026 1095
 									lang('To overwrite the existing file store again.',lang($button)));
1027 1096
 								$content['confirm_overwrite'] = $to;
1028
-								if ($button == 'save') $button = 'apply';
1097
+								if ($button == 'save')
1098
+								{
1099
+									$button = 'apply';
1100
+								}
1029 1101
 								continue;
1030 1102
 							}
1031 1103
 							if (egw_vfs::rename($path,$to))
@@ -1098,13 +1170,19 @@  discard block
 block discarded – undo
1098 1170
 								}
1099 1171
 								if ($ok && !$failed)
1100 1172
 								{
1101
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1173
+									if(!$perm_changed++)
1174
+									{
1175
+										$msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1176
+									}
1102 1177
 									$content['old'][$name] = $content[$name];
1103 1178
 								}
1104 1179
 								elseif($failed)
1105 1180
 								{
1106
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1181
+									if(!$perm_failed++)
1182
+									{
1183
+										$msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1107 1184
 										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1185
+									}
1108 1186
 								}
1109 1187
 							}
1110 1188
 							elseif (call_user_func_array($cmd,array($path,$value)))
@@ -1157,7 +1235,10 @@  discard block
 block discarded – undo
1157 1235
 				}
1158 1236
 			}
1159 1237
 			egw_framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*');
1160
-			if ($button == 'save') egw_framework::window_close();
1238
+			if ($button == 'save')
1239
+			{
1240
+				egw_framework::window_close();
1241
+			}
1161 1242
 		}
1162 1243
 		if ($content['is_link'] && !egw_vfs::stat($path))
1163 1244
 		{
@@ -1167,12 +1248,18 @@  discard block
 block discarded – undo
1167 1248
 		$content['icon'] = egw_vfs::mime_icon($content['mime']);
1168 1249
 		$content['msg'] = $msg;
1169 1250
 
1170
-		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1251
+		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid'])
1252
+		{
1253
+			$content['ro_uid_root'] = 'root';
1254
+		}
1171 1255
 		// only owner can change group & perms
1172 1256
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1173
-			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1257
+			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))
1258
+		{
1259
+			// no uid, gid or perms in oldvfs
1174 1260
 		{
1175 1261
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1262
+		}
1176 1263
 			foreach($content['perms'] as $name => $value)
1177 1264
 			{
1178 1265
 				$readonlys['perms['.$name.']'] = true;
@@ -1205,9 +1292,13 @@  discard block
 block discarded – undo
1205 1292
 				5 => lang('Display of content'),
1206 1293
 				0 => lang('No access'),
1207 1294
 			);
1208
-			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1295
+			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)
1209 1296
 			{
1210
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1297
+				// backend supports eacl
1298
+			{
1299
+				unset($readonlys['tabs']['filemanager.file.eacl']);
1300
+			}
1301
+			// --> switch the tab on again
1211 1302
 				foreach($content['eacl'] as &$eacl)
1212 1303
 				{
1213 1304
 					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
@@ -1264,10 +1355,13 @@  discard block
 block discarded – undo
1264 1355
 				'comment' => (string)$content['comment'],
1265 1356
 				'mergeapp' => $content['mergeapp']
1266 1357
 			);
1267
-			if ($cfs) foreach($cfs as $name => $data)
1358
+			if ($cfs)
1359
+			{
1360
+				foreach($cfs as $name => $data)
1268 1361
 			{
1269 1362
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1270 1363
 			}
1364
+			}
1271 1365
 		}
1272 1366
 		if (egw_vfs::$is_root)
1273 1367
 		{
@@ -1289,7 +1383,10 @@  discard block
 block discarded – undo
1289 1383
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1290 1384
 
1291 1385
 			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1292
-			if (true) $tabs = array();
1386
+			if (true)
1387
+			{
1388
+				$tabs = array();
1389
+			}
1293 1390
 
1294 1391
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1295 1392
 			{
@@ -1342,7 +1439,10 @@  discard block
 block discarded – undo
1342 1439
 			'files' => 0,
1343 1440
 		);
1344 1441
 
1345
-		if (!isset($dir)) $dir = array_pop($selected);
1442
+		if (!isset($dir))
1443
+		{
1444
+			$dir = array_pop($selected);
1445
+		}
1346 1446
 
1347 1447
 		switch($action)
1348 1448
 		{
@@ -1416,7 +1516,10 @@  discard block
 block discarded – undo
1416 1516
 					$target=egw_vfs::concat($dir,egw_vfs::encodePathComponent($file['name']));
1417 1517
 					if (egw_vfs::file_exists($target) && $app_dir)
1418 1518
 					{
1419
-						if (!egw_vfs::file_exists($app_dir)) egw_vfs::mkdir($app_dir);
1519
+						if (!egw_vfs::file_exists($app_dir))
1520
+						{
1521
+							egw_vfs::mkdir($app_dir);
1522
+						}
1420 1523
 						error_log("Symlinking $target to $app_dir");
1421 1524
 						egw_vfs::symlink($target, egw_vfs::concat($app_dir,egw_vfs::encodePathComponent($file['name'])));
1422 1525
 					}
Please login to merge, or discard this patch.
home/inc/class.home_list_portlet.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
 	/**
199 199
 	 * This portlet accepts files and links
200 200
 	 *
201
-	 * @return boolean|String[]
201
+	 * @return string[]
202 202
 	 */
203 203
 	public function accept_drop()
204 204
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * Construct the portlet
39 39
 	 *
40 40
 	 */
41
-	public function __construct(Array &$context = array(), &$need_reload = false)
41
+	public function __construct(array &$context = array(), &$need_reload = false)
42 42
 	{
43 43
 		if (false) parent::__construct();
44 44
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		$content = $this->context;
114 114
 		if(!is_array($content['list']))
115 115
 		{
116
-			$content['list'] = Array();
116
+			$content['list'] = array();
117 117
 		}
118 118
 		// Filemanager support - links need app = 'file' and type set
119 119
 		foreach($content['list'] as &$list)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function __construct(Array &$context = array(), &$need_reload = false)
40 40
 	{
41
-		if(!is_array($context['list'])) $context['list'] = array();
41
+		if (!is_array($context['list'])) $context['list'] = array();
42 42
 
43 43
 		// Process dropped data (Should be GUIDs) into something useable
44
-		if($context['dropped_data'])
44
+		if ($context['dropped_data'])
45 45
 		{
46
-			foreach((Array)$context['dropped_data'] as $dropped)
46
+			foreach ((Array)$context['dropped_data'] as $dropped)
47 47
 			{
48 48
 				$add = array();
49 49
 				list($add['app'], $add['id']) = explode('::', $dropped, 2);
50
-				if($add['app'] && $add['id'])
50
+				if ($add['app'] && $add['id'])
51 51
 				{
52 52
 					$context['list'][] = $add;
53 53
 				}
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 			unset($context['dropped_data']);
57 57
 			$need_reload = true;
58 58
 		}
59
-		if($context['title'])
59
+		if ($context['title'])
60 60
 		{
61 61
 			$this->title = $context['title'];
62 62
 		}
63
-		foreach($context['list'] as &$item)
63
+		foreach ($context['list'] as &$item)
64 64
 		{
65
-			if($item['app'] == 'filemanager' || $item['app'] == 'file')
65
+			if ($item['app'] == 'filemanager' || $item['app'] == 'file')
66 66
 			{
67 67
 				$item['app'] = 'file';
68 68
 				$item['type'] = egw_vfs::mime_content_type($item['id']);
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
 	 * 	unique, if needed.
102 102
 	 * @return string HTML fragment for display
103 103
 	 */
104
-	public function exec($id = null, etemplate_new &$etemplate = null)
104
+	public function exec($id = null, etemplate_new&$etemplate = null)
105 105
 	{
106 106
 		$etemplate->read('home.list');
107 107
 
108 108
 		$etemplate->set_dom_id($id);
109 109
 		$content = $this->context;
110
-		if(!is_array($content['list']))
110
+		if (!is_array($content['list']))
111 111
 		{
112 112
 			$content['list'] = Array();
113 113
 		}
114 114
 		// Filemanager support - links need app = 'file' and type set
115
-		foreach($content['list'] as &$list)
115
+		foreach ($content['list'] as &$list)
116 116
 		{
117
-			if($list['app'] == 'filemanager') $list['app'] = 'file';
118
-			if($list['app'] == 'file')
117
+			if ($list['app'] == 'filemanager') $list['app'] = 'file';
118
+			if ($list['app'] == 'file')
119 119
 			{
120 120
 				$list['app'] = 'file';
121 121
 				$list['path'] = $list['title'] = $list['icon'] = $list['id'];
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			}
124 124
 		}
125 125
 
126
-		$etemplate->exec('home.home_list_portlet.exec',$content);
126
+		$etemplate->exec('home.home_list_portlet.exec', $content);
127 127
 	}
128 128
 
129 129
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 				'type' => 'drop',
179 179
 				'caption' => lang('add'),
180 180
 				'onExecute' => 'javaScript:app.home.add_link',
181
-				'acceptedTypes' => array('file','link') + array_keys($GLOBALS['egw_info']['apps']),
181
+				'acceptedTypes' => array('file', 'link') + array_keys($GLOBALS['egw_info']['apps']),
182 182
 			)
183 183
 		);
184 184
 		return $actions;
@@ -198,6 +198,6 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function accept_drop()
200 200
 	{
201
-		return array('file','link');
201
+		return array('file', 'link');
202 202
 	}
203 203
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,10 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function __construct(Array &$context = array(), &$need_reload = false)
40 40
 	{
41
-		if(!is_array($context['list'])) $context['list'] = array();
41
+		if(!is_array($context['list']))
42
+		{
43
+			$context['list'] = array();
44
+		}
42 45
 
43 46
 		// Process dropped data (Should be GUIDs) into something useable
44 47
 		if($context['dropped_data'])
@@ -114,7 +117,10 @@  discard block
 block discarded – undo
114 117
 		// Filemanager support - links need app = 'file' and type set
115 118
 		foreach($content['list'] as &$list)
116 119
 		{
117
-			if($list['app'] == 'filemanager') $list['app'] = 'file';
120
+			if($list['app'] == 'filemanager')
121
+			{
122
+				$list['app'] = 'file';
123
+			}
118 124
 			if($list['app'] == 'file')
119 125
 			{
120 126
 				$list['app'] = 'file';
Please login to merge, or discard this patch.
home/inc/class.home_portlet.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@
 block discarded – undo
113 113
 	 * If this portlet can be created by dropping, these are the drop types
114 114
 	 * that are accepted
115 115
 	 *
116
-	 * @return boolean|String[]
116
+	 * @return boolean
117 117
 	 */
118 118
 	public function accept_drop()
119 119
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 	 * @param context Array portlet settings such as size, as well as values for properties
35 35
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
36 36
 	 */
37
-	public abstract function __construct(Array &$context = array(), &$need_reload = false);
37
+	public abstract function __construct(array &$context = array(), &$need_reload = false);
38 38
 
39 39
 	/**
40 40
 	 * Some descriptive information about the portlet, so that users can decide if
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * 	unique, if needed.
55 55
 	 * @param etemplate etemplate_new Etemplate to generate content
56 56
 	 */
57
-	public abstract function exec($id = null, etemplate_new &$etemplate = null);
57
+	public abstract function exec($id = null, etemplate_new&$etemplate = null);
58 58
 
59 59
 	/**
60 60
 	 * Return a list of settings to customize the portlet.
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	{
77 77
 		// Include the common attributes, or they won't get saved
78 78
 		$properties = array();
79
-		foreach(self::$common_attributes as $prop)
79
+		foreach (self::$common_attributes as $prop)
80 80
 		{
81 81
 			$properties[$prop] = array('name' => $prop);
82 82
 		}
@@ -121,6 +121,6 @@  discard block
 block discarded – undo
121 121
 
122 122
 	public function __toString()
123 123
 	{
124
-		return get_called_class() . ' Context:' . array2string($this->context);
124
+		return get_called_class().' Context:'.array2string($this->context);
125 125
 	}
126 126
 }
Please login to merge, or discard this patch.
importexport/inc/class.importexport_basic_import_csv.inc.php 5 patches
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,8 +118,7 @@  discard block
 block discarded – undo
118 118
 	/**
119 119
 	 * imports entries according to given definition object.
120 120
 	 * @param resource $_stream
121
-	 * @param string $_charset
122
-	 * @param definition $_definition
121
+	 * @param importexport_definition $_definition
123 122
 	 */
124 123
 	public function import( $_stream, importexport_definition $_definition ) {
125 124
 		$import_csv = new importexport_import_csv( $_stream, array(
@@ -222,7 +221,7 @@  discard block
 block discarded – undo
222 221
 	*
223 222
 	* Updates the count of actions taken
224 223
 	*
225
-	* @return boolean success
224
+	* @return null|boolean success
226 225
 	*/
227 226
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 227
 	{
@@ -274,7 +273,7 @@  discard block
 block discarded – undo
274 273
 	 * @param condition array = array('string' => field name)
275 274
 	 * @param matches - On return, will be filled with matching records
276 275
 	 *
277
-	 * @return boolean
276
+	 * @return boolean|null
278 277
 	 */
279 278
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array())
280 279
 	{
@@ -451,7 +450,7 @@  discard block
 block discarded – undo
451 450
 	/**
452 451
 	 * Allows an extending class to alter a row for preview
453 452
 	 *
454
-	 * @param egw_record $row_entry
453
+	 * @param importexport_iface_egw_record $row_entry
455 454
 	 */
456 455
 	protected function row_preview(importexport_iface_egw_record &$row_entry)
457 456
 	{
@@ -523,7 +522,7 @@  discard block
 block discarded – undo
523 522
 	 * Get the primary key for an entry based on a custom field
524 523
 	 * Returns key, so regular linking can take over
525 524
 	 *
526
-	 * @param int $record_number Row number, used for errors
525
+	 * @param int $record_num Row number, used for errors
527 526
 	 * @param string $app Target application name
528 527
 	 * @param string $value CSV value in the form of custom_field_name:value
529 528
 	 */
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$record_class = isset(static::$record_class) ? static::$record_class : "{$app}_egw_record";
164 164
 
165 165
 		// Needed for categories to work right
166
-        $GLOBALS['egw_info']['flags']['currentapp'] = $app;
166
+		$GLOBALS['egw_info']['flags']['currentapp'] = $app;
167 167
 
168 168
 		$this->init($_definition);
169 169
 
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	/**
218
-	*Import a single record
219
-	*
220
-	* You don't need to worry about mappings or translations, they've been done already.
221
-	* You do need to handle the conditions and the actions taken.
222
-	*
223
-	* Updates the count of actions taken
224
-	*
225
-	* @return boolean success
226
-	*/
218
+	 *Import a single record
219
+	 *
220
+	 * You don't need to worry about mappings or translations, they've been done already.
221
+	 * You do need to handle the conditions and the actions taken.
222
+	 *
223
+	 * Updates the count of actions taken
224
+	 *
225
+	 * @return boolean success
226
+	 */
227 227
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 228
 	{
229 229
 		if ( $this->definition->plugin_options['conditions'] ) {
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 * @param stream $stream
404 404
 	 * @param importexport_definition $definition
405 405
 	 * @return String HTML for preview
406
-         */
406
+	 */
407 407
 	public function preview( $stream, importexport_definition $definition )
408 408
 	{
409 409
 		$this->import($stream, $definition);
@@ -639,37 +639,37 @@  discard block
 block discarded – undo
639 639
 	}
640 640
 
641 641
 	/**
642
-	* Returns warnings that were encountered during importing
643
-	* Maximum of one warning message per record, but you can append if you need to
644
-	*
645
-	* @return Array (
646
-	*       record_# => warning message
647
-	*       )
648
-	*/
642
+	 * Returns warnings that were encountered during importing
643
+	 * Maximum of one warning message per record, but you can append if you need to
644
+	 *
645
+	 * @return Array (
646
+	 *       record_# => warning message
647
+	 *       )
648
+	 */
649 649
 	public function get_warnings() {
650 650
 		return $this->warnings;
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Returns errors that were encountered during importing
655
-	* Maximum of one error message per record, but you can append if you need to
656
-	*
657
-	* @return Array (
658
-	*       record_# => error message
659
-	*       )
660
-	*/
654
+	 * Returns errors that were encountered during importing
655
+	 * Maximum of one error message per record, but you can append if you need to
656
+	 *
657
+	 * @return Array (
658
+	 *       record_# => error message
659
+	 *       )
660
+	 */
661 661
 	public function get_errors() {
662 662
 		return $this->errors;
663 663
 	}
664 664
 
665 665
 	/**
666
-	* Returns a list of actions taken, and the number of records for that action.
667
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
668
-	*
669
-	* @return Array (
670
-	*       action => record count
671
-	* )
672
-	*/
666
+	 * Returns a list of actions taken, and the number of records for that action.
667
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
668
+	 *
669
+	 * @return Array (
670
+	 *       action => record count
671
+	 * )
672
+	 */
673 673
 	public function get_results() {
674 674
 			return $this->results;
675 675
 	}
Please login to merge, or discard this patch.
Braces   +96 added lines, -36 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
18 18
  * should get you started on building a CSV plugin for an application fairly quickly.
19 19
  *
20 20
  */
21
-abstract class importexport_basic_import_csv implements importexport_iface_import_plugin  {
21
+abstract class importexport_basic_import_csv implements importexport_iface_import_plugin
22
+{
22 23
 
23 24
 	protected static $plugin_options = array(
24 25
 		'fieldsep', 		// char
@@ -121,7 +122,8 @@  discard block
 block discarded – undo
121 122
 	 * @param string $_charset
122 123
 	 * @param definition $_definition
123 124
 	 */
124
-	public function import( $_stream, importexport_definition $_definition ) {
125
+	public function import( $_stream, importexport_definition $_definition )
126
+	{
125 127
 		$import_csv = new importexport_import_csv( $_stream, array(
126 128
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
127 129
 			'charset' => $_definition->plugin_options['charset'],
@@ -143,9 +145,12 @@  discard block
 block discarded – undo
143 145
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
144 146
 
145 147
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
148
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
149
+		{
147 150
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
151
+		}
152
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
153
+		{
149 154
 			// First method is preferred
150 155
 			$import_csv->skip_records(1);
151 156
 		}
@@ -167,15 +172,22 @@  discard block
 block discarded – undo
167 172
 
168 173
 		$this->init($_definition);
169 174
 
170
-		while ( $record = $import_csv->get_record() ) {
175
+		while ( $record = $import_csv->get_record() )
176
+		{
171 177
 			$success = false;
172 178
 
173 179
 			// don't import empty records
174
-			if( count( array_unique( $record ) ) < 2 ) continue;
180
+			if( count( array_unique( $record ) ) < 2 )
181
+			{
182
+				continue;
183
+			}
175 184
 
176 185
 
177 186
 			$warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']);
178
-				if($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
187
+				if($warning)
188
+				{
189
+					$this->warnings[$import_csv->get_current_position()] = $warning;
190
+				}
179 191
 
180 192
 			$egw_record = new $record_class();
181 193
 			$egw_record->set_record($record);
@@ -185,7 +197,10 @@  discard block
 block discarded – undo
185 197
 			{
186 198
 				$this->do_special_fields($egw_record, $import_csv);
187 199
 			}
188
-			if($success) $count++;
200
+			if($success)
201
+			{
202
+				$count++;
203
+			}
189 204
 
190 205
 			// Add some more time
191 206
 			if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
@@ -226,10 +241,13 @@  discard block
 block discarded – undo
226 241
 	*/
227 242
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 243
 	{
229
-		if ( $this->definition->plugin_options['conditions'] ) {
230
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
244
+		if ( $this->definition->plugin_options['conditions'] )
245
+		{
246
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
247
+			{
231 248
 				$result = false;
232
-				switch ( $condition['type'] ) {
249
+				switch ( $condition['type'] )
250
+				{
233 251
 					// exists
234 252
 					case 'exists' :
235 253
 						// Check for that record
@@ -257,9 +275,14 @@  discard block
 block discarded – undo
257 275
 					$action = $condition['false'];
258 276
 					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
259 277
 				}
260
-				if ($action['stop']) break;
278
+				if ($action['stop'])
279
+				{
280
+					break;
281
+				}
261 282
 			}
262
-		} else {
283
+		}
284
+		else
285
+		{
263 286
 			// unconditional insert
264 287
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
265 288
 		}
@@ -343,9 +366,14 @@  discard block
 block discarded – undo
343 366
 			return;
344 367
 		}
345 368
 
346
-		foreach(self::$special_fields as $field => $desc) {
347
-			if(!$record->$field) continue;
348
-			if(strpos($field, 'link') === 0) {
369
+		foreach(self::$special_fields as $field => $desc)
370
+		{
371
+			if(!$record->$field)
372
+			{
373
+				continue;
374
+			}
375
+			if(strpos($field, 'link') === 0)
376
+			{
349 377
 				list($app, $app_id) = explode(':', $record->$field,2);
350 378
 
351 379
 				list($link, $type) = explode('_',$field);
@@ -364,7 +392,9 @@  discard block
 block discarded – undo
364 392
 						shift($result);
365 393
 					} while($result && !$app_id);
366 394
 				}
367
-			} else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) {
395
+			}
396
+			else if (in_array($field, array_keys($GLOBALS['egw_info']['apps'])))
397
+			{
368 398
 				$app = $field;
369 399
 				$app_id = $record->$field;
370 400
 
@@ -425,11 +455,16 @@  discard block
 block discarded – undo
425 455
 			$fields = $wizard->get_import_fields();
426 456
 			foreach($labels as $field => &$label)
427 457
 			{
428
-				if($fields[$field]) $label = $fields[$field];
458
+				if($fields[$field])
459
+				{
460
+					$label = $fields[$field];
461
+				}
429 462
 			}
430
-		} catch (Exception $e) {
463
+		}
464
+		catch (Exception $e) {
431 465
 			Api\Translation::add_app($definition->application);
432
-			foreach($labels as $field => &$label) {
466
+			foreach($labels as $field => &$label)
467
+			{
433 468
 				$label = lang($label);
434 469
 			}
435 470
 		}
@@ -468,7 +503,8 @@  discard block
 block discarded – undo
468 503
 	 * @param string $org_name
469 504
 	 * @return int|boolean Contact ID of first match, or false if none found
470 505
 	 */
471
-	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) {
506
+	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null)
507
+	{
472 508
 
473 509
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
474 510
 		static $contacts;
@@ -478,28 +514,40 @@  discard block
 block discarded – undo
478 514
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
479 515
 		}
480 516
 		$n_family = trim($n_family);
481
-		if(!is_null($n_given)) $n_given = trim($n_given);
517
+		if(!is_null($n_given))
518
+		{
519
+			$n_given = trim($n_given);
520
+		}
482 521
 		if (!is_object($contacts))
483 522
 		{
484 523
 			$contacts = new Api\Contacts();
485 524
 		}
486
-		if (!is_null($org_name))	// org_name given?
525
+		if (!is_null($org_name))
526
+		{
527
+			// org_name given?
487 528
 		{
488 529
 			$org_name = trim($org_name);
530
+		}
489 531
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
490 532
 			if (!count($addrs))
491 533
 			{
492 534
 				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
493 535
 			}
494 536
 		}
495
-		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
537
+		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))
538
+		{
539
+			// first name given and no result so far
496 540
 		{
497 541
 			$addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given));
498 542
 		}
499
-		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
543
+		}
544
+		if (is_null($n_given) && is_null($org_name))
545
+		{
546
+			// just one name given, check against fn (= full name)
500 547
 		{
501 548
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
502 549
 		}
550
+		}
503 551
 		if (count($addrs))
504 552
 		{
505 553
 			if(!$record || !$record->get_identifier())
@@ -551,13 +599,17 @@  discard block
 block discarded – undo
551 599
 			}
552 600
 
553 601
 			// Couldn't find field, give an error - something's wrong
554
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
602
+			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)])
603
+			{
555 604
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
556 605
 					$custom_field, lang($app));
557 606
 				return false;
558 607
 			}
559
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
560
-error_log("Searching for $custom_field = $value");
608
+			if($custom_field[0] != '#')
609
+			{
610
+				$custom_field = '#' . $custom_field;
611
+			}
612
+			error_log("Searching for $custom_field = $value");
561 613
 			// Search
562 614
 			if(Link::get_registry($app, 'query'))
563 615
 			{
@@ -591,7 +643,8 @@  discard block
 block discarded – undo
591 643
 	 *
592 644
 	 * @return string name
593 645
 	 */
594
-	public static function get_name() {
646
+	public static function get_name()
647
+	{
595 648
 		return lang('Basic CSV import');
596 649
 	}
597 650
 
@@ -600,7 +653,8 @@  discard block
 block discarded – undo
600 653
 	 *
601 654
 	 * @return string descriprion
602 655
 	 */
603
-	public static function get_description() {
656
+	public static function get_description()
657
+	{
604 658
 		return lang("Imports information from a CSV file.  This is only a base class, and doesn't do anything on its own.");
605 659
 	}
606 660
 
@@ -609,7 +663,8 @@  discard block
 block discarded – undo
609 663
 	 *
610 664
 	 * @return string suffix (comma seperated)
611 665
 	 */
612
-	public static function get_filesuffix() {
666
+	public static function get_filesuffix()
667
+	{
613 668
 		return 'csv';
614 669
 	}
615 670
 
@@ -625,7 +680,8 @@  discard block
 block discarded – undo
625 680
 	 * 		preserv		=> array,
626 681
 	 * )
627 682
 	 */
628
-	public function get_options_etpl() {
683
+	public function get_options_etpl()
684
+	{
629 685
 		// lets do it!
630 686
 	}
631 687
 
@@ -634,7 +690,8 @@  discard block
 block discarded – undo
634 690
 	 *
635 691
 	 * @return string etemplate name
636 692
 	 */
637
-	public function get_selectors_etpl() {
693
+	public function get_selectors_etpl()
694
+	{
638 695
 		// lets do it!
639 696
 	}
640 697
 
@@ -646,7 +703,8 @@  discard block
 block discarded – undo
646 703
 	*       record_# => warning message
647 704
 	*       )
648 705
 	*/
649
-	public function get_warnings() {
706
+	public function get_warnings()
707
+	{
650 708
 		return $this->warnings;
651 709
 	}
652 710
 
@@ -658,7 +716,8 @@  discard block
 block discarded – undo
658 716
 	*       record_# => error message
659 717
 	*       )
660 718
 	*/
661
-	public function get_errors() {
719
+	public function get_errors()
720
+	{
662 721
 		return $this->errors;
663 722
 	}
664 723
 
@@ -670,7 +729,8 @@  discard block
 block discarded – undo
670 729
 	*       action => record count
671 730
 	* )
672 731
 	*/
673
-	public function get_results() {
732
+	public function get_results()
733
+	{
674 734
 			return $this->results;
675 735
 	}
676 736
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return boolean
278 278
 	 */
279
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array())
279
+	protected function exists(importexport_iface_egw_record &$record, array &$condition, &$matches = array())
280 280
 	{
281 281
 	}
282 282
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return boolean
290 290
 	 */
291
-	protected function equal(importexport_iface_egw_record &$record, Array &$condition)
291
+	protected function equal(importexport_iface_egw_record &$record, array &$condition)
292 292
 	{
293 293
 		$field = $condition['string'];
294 294
 		return $record->$field == $condition['op_2'];
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return boolean
305 305
 	 */
306
-	protected function less_than(importexport_iface_egw_record &$record, Array &$condition)
306
+	protected function less_than(importexport_iface_egw_record &$record, array &$condition)
307 307
 	{
308 308
 		$field = $condition['string'];
309 309
 		return $record->$field < $condition['op_2'];
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
  * should get you started on building a CSV plugin for an application fairly quickly.
17 17
  *
18 18
  */
19
-abstract class importexport_basic_import_csv implements importexport_iface_import_plugin  {
19
+abstract class importexport_basic_import_csv implements importexport_iface_import_plugin {
20 20
 
21 21
 	protected static $plugin_options = array(
22
-		'fieldsep', 		// char
23
-		'charset', 			// string
24
-		'record_owner', 	// int
25
-		'update_cats', 			// string {override|add} overides record
22
+		'fieldsep', // char
23
+		'charset', // string
24
+		'record_owner', // int
25
+		'update_cats', // string {override|add} overides record
26 26
 								// with cat(s) from csv OR add the cat from
27 27
 								// csv file to exeisting cat(s) of record
28 28
 		'num_header_lines', // int number of header lines
29 29
 		'field_conversion', // array( $csv_col_num => conversion)
30
-		'field_mapping',	// array( $csv_col_num => adb_filed)
31
-		'conditions',		/* => array containing condition arrays:
30
+		'field_mapping', // array( $csv_col_num => adb_filed)
31
+		'conditions', /* => array containing condition arrays:
32 32
 				'type' => exists, // exists
33 33
 				'string' => '#kundennummer',
34 34
 				'true' => array(
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * Actions wich could be done to data entries
47 47
 	 * If your plugin supports different actions, be sure to modify this array
48 48
 	 */
49
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
49
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
50 50
 
51 51
 	/**
52 52
 	 * Conditions for actions
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @var array
56 56
 	 */
57
-	protected static $conditions = array( 'exists', 'equal', 'less_than');
57
+	protected static $conditions = array('exists', 'equal', 'less_than');
58 58
 
59 59
 	/**
60 60
 	 * This is the definition that will be used to deal with the CSV file
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param string $_charset
120 120
 	 * @param definition $_definition
121 121
 	 */
122
-	public function import( $_stream, importexport_definition $_definition ) {
123
-		$import_csv = new importexport_import_csv( $_stream, array(
122
+	public function import($_stream, importexport_definition $_definition) {
123
+		$import_csv = new importexport_import_csv($_stream, array(
124 124
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
125 125
 			'charset' => $_definition->plugin_options['charset'],
126 126
 		));
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 		$this->definition = $_definition;
129 129
 
130 130
 		// user, is admin ?
131
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
131
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
132 132
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
133 133
 
134 134
 		// dry run?
135
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
135
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
136 136
 
137 137
 		// set FieldMapping.
138 138
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
142 142
 
143 143
 		//check if file has a header lines
144
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
144
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
145 145
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
146
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
146
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
147 147
 			// First method is preferred
148 148
 			$import_csv->skip_records(1);
149 149
 		}
@@ -165,38 +165,38 @@  discard block
 block discarded – undo
165 165
 
166 166
 		$this->init($_definition);
167 167
 
168
-		while ( $record = $import_csv->get_record() ) {
168
+		while ($record = $import_csv->get_record()) {
169 169
 			$success = false;
170 170
 
171 171
 			// don't import empty records
172
-			if( count( array_unique( $record ) ) < 2 ) continue;
172
+			if (count(array_unique($record)) < 2) continue;
173 173
 
174 174
 
175 175
 			$warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']);
176
-				if($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
176
+				if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
177 177
 
178 178
 			$egw_record = new $record_class();
179 179
 			$egw_record->set_record($record);
180 180
 			$success = $this->import_record($egw_record, $import_csv);
181 181
 
182
-			if($success)
182
+			if ($success)
183 183
 			{
184 184
 				$this->do_special_fields($egw_record, $import_csv);
185 185
 			}
186
-			if($success) $count++;
186
+			if ($success) $count++;
187 187
 
188 188
 			// Add some more time
189
-			if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
189
+			if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
190 190
 			{
191 191
 				set_time_limit(10);
192 192
 			}
193 193
 			
194 194
 			// Keep a few records for preview, but process the whole file
195
-			if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
195
+			if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
196 196
 			{
197 197
 				$this->preview_records[] = $egw_record;
198 198
 			}
199
-			if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
199
+			if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
200 200
 			{
201 201
 				$this->errors[] = 'Too many errors, aborted';
202 202
 				break;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	/**
209 209
 	 * Stub to hook into import initialization - set lookups, etc.
210 210
 	 */
211
-	protected function init(importexport_definition &$definition)
211
+	protected function init(importexport_definition&$definition)
212 212
 	{
213 213
 	}
214 214
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 	*
223 223
 	* @return boolean success
224 224
 	*/
225
-	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
225
+	protected function import_record(importexport_iface_egw_record&$record, &$import_csv)
226 226
 	{
227
-		if ( $this->definition->plugin_options['conditions'] ) {
228
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
227
+		if ($this->definition->plugin_options['conditions']) {
228
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
229 229
 				$result = false;
230
-				switch ( $condition['type'] ) {
230
+				switch ($condition['type']) {
231 231
 					// exists
232 232
 					case 'exists' :
233 233
 						// Check for that record
@@ -243,23 +243,23 @@  discard block
 block discarded – undo
243 243
 						die('condition / action not supported!!!');
244 244
 						break;
245 245
 				}
246
-				if($result)
246
+				if ($result)
247 247
 				{
248 248
 					// Apply true action to any matching records found
249 249
 					$action = $condition['true'];
250
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
250
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
251 251
 				}
252 252
 				else
253 253
 				{
254 254
 					// Apply false action if no matching records found
255 255
 					$action = $condition['false'];
256
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
256
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
257 257
 				}
258 258
 				if ($action['stop']) break;
259 259
 			}
260 260
 		} else {
261 261
 			// unconditional insert
262
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
262
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
263 263
 		}
264 264
 
265 265
 		return $success;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return boolean
276 276
 	 */
277
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array())
277
+	protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$matches = array())
278 278
 	{
279 279
 	}
280 280
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @return boolean
288 288
 	 */
289
-	protected function equal(importexport_iface_egw_record &$record, Array &$condition)
289
+	protected function equal(importexport_iface_egw_record&$record, Array &$condition)
290 290
 	{
291 291
 		$field = $condition['string'];
292 292
 		return $record->$field == $condition['op_2'];
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 *
302 302
 	 * @return boolean
303 303
 	 */
304
-	protected function less_than(importexport_iface_egw_record &$record, Array &$condition)
304
+	protected function less_than(importexport_iface_egw_record&$record, Array &$condition)
305 305
 	{
306 306
 		$field = $condition['string'];
307 307
 		return $record->$field < $condition['op_2'];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param int $record_num Which record number is being dealt with.  Used for error messages.
321 321
 	 * @return bool success or not
322 322
 	 */
323
-	protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 );
323
+	protected abstract function action($_action, importexport_iface_egw_record&$record, $record_num = 0);
324 324
 
325 325
 	/**
326 326
 	 * Handle special fields
@@ -330,51 +330,51 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @param importexport_iface_egw_record $record
332 332
 	 */
333
-	protected function do_special_fields(importexport_iface_egw_record &$record, &$import_csv)
333
+	protected function do_special_fields(importexport_iface_egw_record&$record, &$import_csv)
334 334
 	{
335 335
 		$id = $record->get_identifier();
336 336
 
337 337
 		// Warn if there's no ID unless it's a dry_run because there probably won't be an ID then
338
-		if(!$this->dry_run && !$id)
338
+		if (!$this->dry_run && !$id)
339 339
 		{
340 340
 			$this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record";
341 341
 			return;
342 342
 		}
343 343
 
344
-		foreach(self::$special_fields as $field => $desc) {
345
-			if(!$record->$field) continue;
346
-			if(strpos($field, 'link') === 0) {
347
-				list($app, $app_id) = explode(':', $record->$field,2);
344
+		foreach (self::$special_fields as $field => $desc) {
345
+			if (!$record->$field) continue;
346
+			if (strpos($field, 'link') === 0) {
347
+				list($app, $app_id) = explode(':', $record->$field, 2);
348 348
 
349
-				list($link, $type) = explode('_',$field);
349
+				list($link, $type) = explode('_', $field);
350 350
 
351 351
 				// Searching, take first result
352
-				if($type == 'custom')
352
+				if ($type == 'custom')
353 353
 				{
354 354
 					$app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position());
355 355
 				}
356
-				else if($type == 'search')
356
+				else if ($type == 'search')
357 357
 				{
358 358
 					$result = egw_link::query($app, $app_id);
359 359
 					do
360 360
 					{
361 361
 						$app_id = key($result);
362 362
 						shift($result);
363
-					} while($result && !$app_id);
363
+					} while ($result && !$app_id);
364 364
 				}
365 365
 			} else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) {
366 366
 				$app = $field;
367 367
 				$app_id = $record->$field;
368 368
 
369 369
 				// Searching, take first result
370
-				if(!is_numeric($app_id))
370
+				if (!is_numeric($app_id))
371 371
 				{
372 372
 					$result = egw_link::query($app, $app_id);
373 373
 					do
374 374
 					{
375 375
 						$app_id = key($result);
376 376
 						shift($result);
377
-					} while($result && !$app_id);
377
+					} while ($result && !$app_id);
378 378
 				}
379 379
 			}
380 380
 			else if ($field == 'contact')
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			}
386 386
 			if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id))
387 387
 			{
388
-				$link_id = egw_link::link($this->definition->application,$id,$app,$app_id);
388
+				$link_id = egw_link::link($this->definition->application, $id, $app, $app_id);
389 389
 			}
390 390
 		}
391 391
 	}
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
 	 * @param importexport_definition $definition
403 403
 	 * @return String HTML for preview
404 404
          */
405
-	public function preview( $stream, importexport_definition $definition )
405
+	public function preview($stream, importexport_definition $definition)
406 406
 	{
407 407
 		$this->import($stream, $definition);
408 408
 		rewind($stream);
409 409
 
410 410
 		// Set up result
411
-		$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
411
+		$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
412 412
 
413 413
 		// Load labels for app
414 414
 		$record_class = get_class($this->preview_records[0]);
@@ -417,27 +417,27 @@  discard block
 block discarded – undo
417 417
 		$labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']);
418 418
 
419 419
 		$plugin = get_called_class();
420
-		$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
420
+		$wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin);
421 421
 		try {
422 422
 			$wizard = new $wizard_name;
423 423
 			$fields = $wizard->get_import_fields();
424
-			foreach($labels as $field => &$label)
424
+			foreach ($labels as $field => &$label)
425 425
 			{
426
-				if($fields[$field]) $label = $fields[$field];
426
+				if ($fields[$field]) $label = $fields[$field];
427 427
 			}
428 428
 		} catch (Exception $e) {
429 429
 			translation::add_app($definition->application);
430
-			foreach($labels as $field => &$label) {
430
+			foreach ($labels as $field => &$label) {
431 431
 				$label = lang($label);
432 432
 			}
433 433
 		}
434 434
 
435 435
 		// Set up HTML
436 436
 		$rows['h1'] = $labels;
437
-		foreach($this->preview_records as $i => $row_data)
437
+		foreach ($this->preview_records as $i => $row_data)
438 438
 		{
439 439
 			// Convert to human-friendly
440
-			importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups);
440
+			importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups);
441 441
 			$this->row_preview($row_data);
442 442
 			$rows[] = $row_data->get_record_array();
443 443
 		}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @param egw_record $row_entry
453 453
 	 */
454
-	protected function row_preview(importexport_iface_egw_record &$row_entry)
454
+	protected function row_preview(importexport_iface_egw_record&$row_entry)
455 455
 	{
456 456
 	}
457 457
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @param string $org_name
467 467
 	 * @return int|boolean Contact ID of first match, or false if none found
468 468
 	 */
469
-	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) {
469
+	public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) {
470 470
 
471 471
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
472 472
 		static $contacts;
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
477 477
 		}
478 478
 		$n_family = trim($n_family);
479
-		if(!is_null($n_given)) $n_given = trim($n_given);
479
+		if (!is_null($n_given)) $n_given = trim($n_given);
480 480
 		if (!is_object($contacts))
481 481
 		{
482
-			$contacts =& CreateObject('phpgwapi.contacts');
482
+			$contacts = & CreateObject('phpgwapi.contacts');
483 483
 		}
484 484
 		if (!is_null($org_name))	// org_name given?
485 485
 		{
486 486
 			$org_name = trim($org_name);
487
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
487
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
488 488
 			if (!count($addrs))
489 489
 			{
490
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
490
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
491 491
 			}
492 492
 		}
493 493
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -496,11 +496,11 @@  discard block
 block discarded – undo
496 496
 		}
497 497
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
498 498
 		{
499
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
499
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
500 500
 		}
501 501
 		if (count($addrs))
502 502
 		{
503
-			if(!$record || !$record->get_identifier())
503
+			if (!$record || !$record->get_identifier())
504 504
 			{
505 505
 				return $addrs[0]['id'];
506 506
 			}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 				{
511 511
 					$id = key($addrs);
512 512
 					array_shift($addrs);
513
-				} while($addrs && !$id && $id == $record->get_identifier());
513
+				} while ($addrs && !$id && $id == $record->get_identifier());
514 514
 				return $id;
515 515
 			}
516 516
 		}
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
 	 * @param string $app Target application name
526 526
 	 * @param string $value CSV value in the form of custom_field_name:value
527 527
 	 */
528
-	protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num)
528
+	protected function link_by_cf(importexport_iface_egw_record&$record, $app, $value, $record_num)
529 529
 	{
530 530
 		$app_id = false;
531 531
 
532
-		list($custom_field, $value) = explode(':',$value);
532
+		list($custom_field, $value) = explode(':', $value);
533 533
 		// Find matching entry
534
-		if($app && $custom_field && $value)
534
+		if ($app && $custom_field && $value)
535 535
 		{
536 536
 			$cfs = config::get_customfields($app);
537 537
 			// Error if no custom fields, probably something wrong in definition
538
-			if(!$cfs[$custom_field])
538
+			if (!$cfs[$custom_field])
539 539
 			{
540 540
 				// Check for users specifing label instead of name
541
-				foreach($cfs as $name => $settings)
541
+				foreach ($cfs as $name => $settings)
542 542
 				{
543
-					if(strtolower($settings['label']) == strtolower($custom_field))
543
+					if (strtolower($settings['label']) == strtolower($custom_field))
544 544
 					{
545 545
 						$custom_field = $name;
546 546
 						break;
@@ -549,30 +549,30 @@  discard block
 block discarded – undo
549 549
 			}
550 550
 
551 551
 			// Couldn't find field, give an error - something's wrong
552
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
552
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
553 553
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
554 554
 					$custom_field, lang($app));
555 555
 				return false;
556 556
 			}
557
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
557
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
558 558
 error_log("Searching for $custom_field = $value");
559 559
 			// Search
560
-			if(egw_link::get_registry($app, 'query'))
560
+			if (egw_link::get_registry($app, 'query'))
561 561
 			{
562
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
562
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
563 563
 				$result = egw_link::query($app, '', $options);
564 564
 
565 565
 				// Only one allowed
566
-				if($record->get_identifier())
566
+				if ($record->get_identifier())
567 567
 				{
568
-					while(key($result) == $record->get_identifier())
568
+					while (key($result) == $record->get_identifier())
569 569
 					{
570 570
 						array_shift($result);
571 571
 					}
572 572
 				}
573
-				if(count($result) != 1)
573
+				if (count($result) != 1)
574 574
 				{
575
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
575
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
576 576
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
577 577
 						$custom_field, count($result), lang($app), $options['filter'][0]
578 578
 					);
Please login to merge, or discard this patch.
importexport/inc/class.importexport_definition.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,6 @@
 block discarded – undo
176 176
 	/**
177 177
 	 * sets options
178 178
 	 *
179
-	 * @param array $options
180 179
 	 */
181 180
 	private function set_options(array $_plugin_options) {
182 181
 		$this->definition['plugin_options'] = $_plugin_options;
Please login to merge, or discard this patch.
Braces   +82 added lines, -39 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
  * are in one assiozative array which is complely managed by {Im|Ex}port plugins
21 21
  * @todo testing
22 22
  */
23
-class importexport_definition implements importexport_iface_egw_record {
23
+class importexport_definition implements importexport_iface_egw_record
24
+{
24 25
 
25 26
 	const _appname = 'importexport';
26 27
 	const _defintion_talbe = 'egw_importexport_definitions';
@@ -65,26 +66,36 @@  discard block
 block discarded – undo
65 66
 	 *
66 67
 	 * @param string $_identifier
67 68
 	 */
68
-	public function __construct( $_identifier='' ) {
69
+	public function __construct( $_identifier='' )
70
+	{
69 71
 		$this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe);
70 72
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
71 73
 		$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
72 74
 		// compability to string identifiers
73
-		if (!is_numeric($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier);
75
+		if (!is_numeric($_identifier) && strlen($_identifier) > 3)
76
+		{
77
+			$_identifier = $this->name2identifier($_identifier);
78
+		}
74 79
 
75
-		if ((int)$_identifier != 0) {
80
+		if ((int)$_identifier != 0)
81
+		{
76 82
 			$this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
77
-			if ( empty( $this->definition ) ) {
83
+			if ( empty( $this->definition ) )
84
+			{
78 85
 				throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
79 86
 			}
80
-			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
87
+			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin))
88
+			{
81 89
 				throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
82 90
 			}
83 91
 			try
84 92
 			{
85 93
 				$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
86 94
 				$this->definition['plugin_options'] = $options_data['root'];
87
-				if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
95
+				if($this->definition['filter'])
96
+				{
97
+					$filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
98
+				}
88 99
 				$this->definition['filter'] = $filter['root'];
89 100
 			}
90 101
 			catch (Exception $e)
@@ -100,12 +111,15 @@  discard block
 block discarded – undo
100 111
 	 * @param string $_name
101 112
 	 * @return int
102 113
 	 */
103
-	private function name2identifier( $_name ) {
114
+	private function name2identifier( $_name )
115
+	{
104 116
 		$identifiers = $this->so_sql->search(array('name' => $_name),true);
105
-		if (isset($identifiers[1])) {
117
+		if (isset($identifiers[1]))
118
+		{
106 119
 			throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
107 120
 		}
108
-		if ( empty( $identifiers[0] ) ) {
121
+		if ( empty( $identifiers[0] ) )
122
+		{
109 123
 			// not a good idea, till we don't have different exceptions so far
110 124
 			// throw new Exception('Error: No such definition :"'.$_name.'"!');
111 125
 			$identifiers = array( array( 'definition_id' => 0 ) );
@@ -113,11 +127,14 @@  discard block
 block discarded – undo
113 127
 		return $identifiers[0]['definition_id'];
114 128
 	}
115 129
 
116
-	public function __get($_attribute_name) {
117
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
130
+	public function __get($_attribute_name)
131
+	{
132
+		if (!array_key_exists($_attribute_name,$this->attributes))
133
+		{
118 134
 			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
119 135
 		}
120
-		switch ($_attribute_name) {
136
+		switch ($_attribute_name)
137
+		{
121 138
 			case 'allowed_users' :
122 139
 				return $this->get_allowed_users();
123 140
 			case 'plugin_options' :
@@ -129,11 +146,14 @@  discard block
 block discarded – undo
129 146
 		}
130 147
 	}
131 148
 
132
-	public function __set($_attribute_name,$_data) {
133
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
149
+	public function __set($_attribute_name,$_data)
150
+	{
151
+		if (!array_key_exists($_attribute_name,$this->attributes))
152
+		{
134 153
 			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
135 154
 		}
136
-		switch ($_attribute_name) {
155
+		switch ($_attribute_name)
156
+		{
137 157
 			case 'allowed_users' :
138 158
 				return $this->set_allowed_users($_data);
139 159
 			case 'plugin_options' :
@@ -151,7 +171,8 @@  discard block
 block discarded – undo
151 171
 	 *
152 172
 	 * @return array
153 173
 	 */
154
-	private function get_allowed_users() {
174
+	private function get_allowed_users()
175
+	{
155 176
 		return explode(',',substr($this->definition['allowed_users'],1,-1));
156 177
 	}
157 178
 
@@ -160,7 +181,8 @@  discard block
 block discarded – undo
160 181
 	 *
161 182
 	 * @param array $_allowed_users
162 183
 	 */
163
-	private function set_allowed_users( $_allowed_users ) {
184
+	private function set_allowed_users( $_allowed_users )
185
+	{
164 186
 		$this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .',';
165 187
 	}
166 188
 
@@ -169,7 +191,8 @@  discard block
 block discarded – undo
169 191
 	 *
170 192
 	 * @return array
171 193
 	 */
172
-	private function get_options() {
194
+	private function get_options()
195
+	{
173 196
 		return $this->definition['plugin_options'];
174 197
 	}
175 198
 
@@ -178,7 +201,8 @@  discard block
 block discarded – undo
178 201
 	 *
179 202
 	 * @param array $options
180 203
 	 */
181
-	private function set_options(array $_plugin_options) {
204
+	private function set_options(array $_plugin_options)
205
+	{
182 206
 		$this->definition['plugin_options'] = $_plugin_options;
183 207
 	}
184 208
 
@@ -187,7 +211,8 @@  discard block
 block discarded – undo
187 211
 	 *
188 212
 	 * @return array
189 213
 	 */
190
-	private function get_filter() {
214
+	private function get_filter()
215
+	{
191 216
 		return $this->definition['filter'];
192 217
 	}
193 218
 
@@ -196,7 +221,8 @@  discard block
 block discarded – undo
196 221
 	 *
197 222
 	 * @param filter array of field => settings
198 223
 	 */
199
-	private function set_filter(Array $filter) {
224
+	private function set_filter(Array $filter)
225
+	{
200 226
 		$this->definition['filter'] = $filter;
201 227
 	}
202 228
 
@@ -208,7 +234,8 @@  discard block
 block discarded – undo
208 234
 	 *
209 235
 	 * @return array complete record as associative array
210 236
 	 */
211
-	public function get_record_array() {
237
+	public function get_record_array()
238
+	{
212 239
 		$definition = $this->definition;
213 240
 		$definition['allowed_users'] = $this->get_allowed_users();
214 241
 		$definition['plugin_options'] = $this->get_options();
@@ -221,7 +248,8 @@  discard block
 block discarded – undo
221 248
 	 *
222 249
 	 *@return string tiltle
223 250
 	 */
224
-	public function get_title() {
251
+	public function get_title()
252
+	{
225 253
 		return $this->definition['name'];
226 254
 	}
227 255
 
@@ -230,13 +258,16 @@  discard block
 block discarded – undo
230 258
 	 *
231 259
 	 * @return void
232 260
 	 */
233
-	public function set_record( array $_record ) {
261
+	public function set_record( array $_record )
262
+	{
234 263
 		$this->definition = array_intersect_key( $_record, $this->attributes );
235 264
 
236 265
 		// anything which is not an attribute is perhaps a plugin_option.
237 266
 		// If not, it gets whiped out on save time.
238
-		foreach ( $_record as $attribute => $value) {
239
-			if ( !array_key_exists( $attribute, $this->attributes ) ) {
267
+		foreach ( $_record as $attribute => $value)
268
+		{
269
+			if ( !array_key_exists( $attribute, $this->attributes ) )
270
+			{
240 271
 				$this->definition['plugin_options'][$attribute] = $value;
241 272
 			}
242 273
 		}
@@ -254,7 +285,8 @@  discard block
 block discarded – undo
254 285
 	 *
255 286
 	 * @return int identifier of this record
256 287
 	 */
257
-	public function get_identifier() {
288
+	public function get_identifier()
289
+	{
258 290
 		return $this->definition['definition_id'];
259 291
 	}
260 292
 
@@ -265,7 +297,8 @@  discard block
 block discarded – undo
265 297
 	 *
266 298
 	 * @return string Full URL of an icon, or appname/icon_name
267 299
 	 */
268
-	public function get_icon() {
300
+	public function get_icon()
301
+	{
269 302
 		return self::_appname . '/navbar';
270 303
 	}
271 304
 
@@ -274,8 +307,10 @@  discard block
 block discarded – undo
274 307
 	 *
275 308
 	 * @return string identifier
276 309
 	 */
277
-	public function save ( $_dst_identifier ) {
278
-		if ( strlen($this->definition['name']) < 3 ) {
310
+	public function save ( $_dst_identifier )
311
+	{
312
+		if ( strlen($this->definition['name']) < 3 )
313
+		{
279 314
 			throw new Exception('Error: Can\'t save definition, no valid name given!');
280 315
 		}
281 316
 
@@ -283,7 +318,8 @@  discard block
 block discarded – undo
283 318
 		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
284 319
 		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
285 320
 		$this->so_sql->data['modified'] = time();
286
-		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
321
+		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier )))
322
+		{
287 323
 			throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier());
288 324
 		}
289 325
 
@@ -296,7 +332,8 @@  discard block
 block discarded – undo
296 332
 	 * @param string $_dst_identifier
297 333
 	 * @return string dst_identifier
298 334
 	 */
299
-	public function copy ( $_dst_identifier ) {
335
+	public function copy ( $_dst_identifier )
336
+	{
300 337
 		$dst_object = clone $this;
301 338
 		try {
302 339
 			$dst_object->set_owner($this->user);
@@ -317,8 +354,10 @@  discard block
 block discarded – undo
317 354
 	 * @param string $_dst_identifier
318 355
 	 * @return string dst_identifier
319 356
 	 */
320
-	public function move ( $_dst_identifier ) {
321
-		if ($this->user != $this->get_owner() && !$this->is_admin) {
357
+	public function move ( $_dst_identifier )
358
+	{
359
+		if ($this->user != $this->get_owner() && !$this->is_admin)
360
+		{
322 361
 			throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier());
323 362
 		}
324 363
 		$old_object = clone $this;
@@ -339,11 +378,14 @@  discard block
 block discarded – undo
339 378
 	 * @return void
340 379
 	 *
341 380
 	 */
342
-	public function delete () {
343
-		if($this->user != $this->get_owner() && !$this->is_admin) {
381
+	public function delete ()
382
+	{
383
+		if($this->user != $this->get_owner() && !$this->is_admin)
384
+		{
344 385
 			throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
345 386
 		}
346
-		if(!$this->so_sql->delete()) {
387
+		if(!$this->so_sql->delete())
388
+		{
347 389
 			throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier());
348 390
 		}
349 391
 	}
@@ -352,7 +394,8 @@  discard block
 block discarded – undo
352 394
 	 * destructor
353 395
 	 *
354 396
 	 */
355
-	public function __destruct() {
397
+	public function __destruct()
398
+	{
356 399
 		unset($this->so_sql);
357 400
 	}
358 401
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@
 block discarded – undo
196 196
 	 *
197 197
 	 * @param filter array of field => settings
198 198
 	 */
199
-	private function set_filter(Array $filter) {
199
+	private function set_filter(array $filter) {
200 200
 		$this->definition['filter'] = $filter;
201 201
 	}
202 202
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param string $_identifier
65 65
 	 */
66
-	public function __construct( $_identifier='' ) {
67
-		$this->so_sql = new so_sql(self::_appname ,self::_defintion_talbe);
66
+	public function __construct($_identifier = '') {
67
+		$this->so_sql = new so_sql(self::_appname, self::_defintion_talbe);
68 68
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
69 69
 		$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
70 70
 		// compability to string identifiers
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 
73 73
 		if ((int)$_identifier != 0) {
74 74
 			$this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
75
-			if ( empty( $this->definition ) ) {
75
+			if (empty($this->definition)) {
76 76
 				throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
77 77
 			}
78
-			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
78
+			if (!(importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
79 79
 				throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
80 80
 			}
81 81
 			try
82 82
 			{
83
-				$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
83
+				$options_data = importexport_arrayxml::xml2array($this->definition['plugin_options']);
84 84
 				$this->definition['plugin_options'] = $options_data['root'];
85
-				if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
85
+				if ($this->definition['filter']) $filter = importexport_arrayxml::xml2array($this->definition['filter']);
86 86
 				$this->definition['filter'] = $filter['root'];
87 87
 			}
88 88
 			catch (Exception $e)
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 	 * @param string $_name
99 99
 	 * @return int
100 100
 	 */
101
-	private function name2identifier( $_name ) {
102
-		$identifiers = $this->so_sql->search(array('name' => $_name),true);
101
+	private function name2identifier($_name) {
102
+		$identifiers = $this->so_sql->search(array('name' => $_name), true);
103 103
 		if (isset($identifiers[1])) {
104
-			throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
104
+			throw new Exception('Error: Definition: "'.$_name.'" is not unique! Can\'t convert to identifier');
105 105
 		}
106
-		if ( empty( $identifiers[0] ) ) {
106
+		if (empty($identifiers[0])) {
107 107
 			// not a good idea, till we don't have different exceptions so far
108 108
 			// throw new Exception('Error: No such definition :"'.$_name.'"!');
109
-			$identifiers = array( array( 'definition_id' => 0 ) );
109
+			$identifiers = array(array('definition_id' => 0));
110 110
 		}
111 111
 		return $identifiers[0]['definition_id'];
112 112
 	}
113 113
 
114 114
 	public function __get($_attribute_name) {
115
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
116
-			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
115
+		if (!array_key_exists($_attribute_name, $this->attributes)) {
116
+			throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion');
117 117
 		}
118 118
 		switch ($_attribute_name) {
119 119
 			case 'allowed_users' :
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 	}
129 129
 
130
-	public function __set($_attribute_name,$_data) {
131
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
132
-			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
130
+	public function __set($_attribute_name, $_data) {
131
+		if (!array_key_exists($_attribute_name, $this->attributes)) {
132
+			throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion');
133 133
 		}
134 134
 		switch ($_attribute_name) {
135 135
 			case 'allowed_users' :
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @return array
151 151
 	 */
152 152
 	private function get_allowed_users() {
153
-		return explode(',',substr($this->definition['allowed_users'],1,-1));
153
+		return explode(',', substr($this->definition['allowed_users'], 1, -1));
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @param array $_allowed_users
160 160
 	 */
161
-	private function set_allowed_users( $_allowed_users ) {
162
-		$this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .',';
161
+	private function set_allowed_users($_allowed_users) {
162
+		$this->definition['allowed_users'] = ','.implode(',', (array)$_allowed_users).',';
163 163
 	}
164 164
 
165 165
 	/**
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return void
230 230
 	 */
231
-	public function set_record( array $_record ) {
232
-		$this->definition = array_intersect_key( $_record, $this->attributes );
231
+	public function set_record(array $_record) {
232
+		$this->definition = array_intersect_key($_record, $this->attributes);
233 233
 
234 234
 		// anything which is not an attribute is perhaps a plugin_option.
235 235
 		// If not, it gets whiped out on save time.
236
-		foreach ( $_record as $attribute => $value) {
237
-			if ( !array_key_exists( $attribute, $this->attributes ) ) {
236
+		foreach ($_record as $attribute => $value) {
237
+			if (!array_key_exists($attribute, $this->attributes)) {
238 238
 				$this->definition['plugin_options'][$attribute] = $value;
239 239
 			}
240 240
 		}
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 		$this->plugin = $_record['plugin'];
243 243
 
244 244
 		// convert plugin_options into internal representation
245
-		$this->set_allowed_users( $this->definition['allowed_users'] );
246
-		$this->set_options( $this->definition['plugin_options'] ? $this->definition['plugin_options'] : array());
247
-		$this->set_filter( $this->definition['filter'] ? $this->definition['filter'] : array());
245
+		$this->set_allowed_users($this->definition['allowed_users']);
246
+		$this->set_options($this->definition['plugin_options'] ? $this->definition['plugin_options'] : array());
247
+		$this->set_filter($this->definition['filter'] ? $this->definition['filter'] : array());
248 248
 	}
249 249
 
250 250
 	/**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @return string Full URL of an icon, or appname/icon_name
265 265
 	 */
266 266
 	public function get_icon() {
267
-		return self::_appname . '/navbar';
267
+		return self::_appname.'/navbar';
268 268
 	}
269 269
 
270 270
 	/**
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return string identifier
274 274
 	 */
275
-	public function save ( $_dst_identifier ) {
276
-		if ( strlen($this->definition['name']) < 3 ) {
275
+	public function save($_dst_identifier) {
276
+		if (strlen($this->definition['name']) < 3) {
277 277
 			throw new Exception('Error: Can\'t save definition, no valid name given!');
278 278
 		}
279 279
 
280 280
 		$this->so_sql->data = $this->definition;
281
-		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
282
-		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
281
+		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml($this->definition['plugin_options']);
282
+		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml($this->definition['filter']);
283 283
 		$this->so_sql->data['modified'] = time();
284
-		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
284
+		if ($this->so_sql->save(array('definition_id' => $_dst_identifier))) {
285 285
 			throw new Exception('Error: so_sql was not able to save definition: '.$this->get_identifier());
286 286
 		}
287 287
 
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 	 * @param string $_dst_identifier
295 295
 	 * @return string dst_identifier
296 296
 	 */
297
-	public function copy ( $_dst_identifier ) {
297
+	public function copy($_dst_identifier) {
298 298
 		$dst_object = clone $this;
299 299
 		try {
300 300
 			$dst_object->set_owner($this->user);
301 301
 			$dst_identifier = $dst_object->save($_dst_identifier);
302 302
 		}
303
-		catch(exception $Exception) {
303
+		catch (exception $Exception) {
304 304
 			unset($dst_object);
305 305
 			throw $Exception;
306 306
 		}
@@ -315,16 +315,16 @@  discard block
 block discarded – undo
315 315
 	 * @param string $_dst_identifier
316 316
 	 * @return string dst_identifier
317 317
 	 */
318
-	public function move ( $_dst_identifier ) {
318
+	public function move($_dst_identifier) {
319 319
 		if ($this->user != $this->get_owner() && !$this->is_admin) {
320
-			throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier());
320
+			throw('Error: User '.$this->user.'does not have permissions to move definition '.$this->get_identifier());
321 321
 		}
322 322
 		$old_object = clone $this;
323 323
 		try {
324 324
 			$dst_identifier = $this->save($_dst_identifier);
325 325
 			$old_object->delete();
326 326
 		}
327
-		catch(exception $Exception) {
327
+		catch (exception $Exception) {
328 328
 			unset($old_object);
329 329
 			throw $Exception;
330 330
 		}
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	 * @return void
338 338
 	 *
339 339
 	 */
340
-	public function delete () {
341
-		if($this->user != $this->get_owner() && !$this->is_admin) {
342
-			throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
340
+	public function delete() {
341
+		if ($this->user != $this->get_owner() && !$this->is_admin) {
342
+			throw('Error: User '.$this->user.'does not have permissions to delete definition '.$this->get_identifier());
343 343
 		}
344
-		if(!$this->so_sql->delete()) {
344
+		if (!$this->so_sql->delete()) {
345 345
 			throw('Error: so_sql was not able to delete definition: '.$this->get_identifier());
346 346
 		}
347 347
 	}
Please login to merge, or discard this patch.