Completed
Push — 17.1 ( 8c3b94...29ee37 )
by Ralf
20:39 queued 11:58
created
doc/fix_depricated.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * Fix depricated stuff in a given file
24 24
  *
25 25
  * @param string $file filename
26
- * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
26
+ * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created
27 27
  * @return boolean false on error
28 28
  */
29 29
 function fix_depricated($file,$replace_file=false)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
  * Loop recursive through directory and call fix_depricated for each php file
147 147
  *
148 148
  * @param string $dir
149
- * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
149
+ * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created
150 150
  * @return boolean false on error
151 151
  */
152 152
 function fix_depricated_recursive($dir,$replace_file=false)
@@ -174,7 +174,6 @@  discard block
 block discarded – undo
174 174
 /**
175 175
  * Give usage
176 176
  *
177
- * @param string $error=null
178 177
  */
179 178
 function usage($error=null)
180 179
 {
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -26,47 +26,47 @@  discard block
 block discarded – undo
26 26
  * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
27 27
  * @return boolean false on error
28 28
  */
29
-function fix_depricated($file,$replace_file=false)
29
+function fix_depricated($file, $replace_file = false)
30 30
 {
31 31
 	$orig = $lines = file_get_contents($file);
32 32
 	if ($lines === false) return false;
33 33
 	global $prog;
34
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
34
+	if (basename($file) == $prog) return true; // dont fix ourself ;-)
35 35
 
36 36
 	// PHP Deprecated:  Assigning the return value of new by reference is deprecated
37
-	if (preg_match('/= *& *new /m',$lines))
37
+	if (preg_match('/= *& *new /m', $lines))
38 38
 	{
39
-		$lines = preg_replace('/= *& *new /','= new ',$lines);
39
+		$lines = preg_replace('/= *& *new /', '= new ', $lines);
40 40
 	}
41 41
 	// PHP Deprecated:  Function split() is deprecated
42
-	if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m',$lines,$matches))
42
+	if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m', $lines, $matches))
43 43
 	{
44 44
 		$replace = array();
45 45
 		//print_r($matches);
46
-		foreach($matches[1] as $key => $pattern)
46
+		foreach ($matches[1] as $key => $pattern)
47 47
 		{
48 48
 			$full_pattern = $matches[0][$key];
49 49
 			// single char --> just explode
50
-			if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern,0,2) == '"\\')
50
+			if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern, 0, 2) == '"\\')
51 51
 			{
52
-				$replace[$full_pattern] = str_replace('split','explode',$full_pattern);
52
+				$replace[$full_pattern] = str_replace('split', 'explode', $full_pattern);
53 53
 			}
54 54
 			else
55 55
 			{
56
-				$preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0];
57
-				if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
58
-				$replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern);
56
+				$preg_pattern = $pattern[0].'/'.str_replace('/', '\\\\/', substr($pattern, 1, -1)).'/'.$pattern[0];
57
+				if (strpos($full_pattern, 'spliti')) $preg_pattern = substr($preg_pattern, 0, -1).'i'.$pattern[0];
58
+				$replace[$full_pattern] = str_replace(array('spliti', 'split', $pattern), array('preg_split', 'preg_split', $preg_pattern), $full_pattern);
59 59
 			}
60 60
 		}
61 61
 		//print_r($replace);
62
-		$lines = strtr($lines,$replace);
62
+		$lines = strtr($lines, $replace);
63 63
 	}
64 64
 	// PHP Deprecated:  Function ereg() is deprecated
65
-	if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m',$lines,$matches))
65
+	if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m', $lines, $matches))
66 66
 	{
67 67
 		$replace = array();
68 68
 		//print_r($matches);
69
-		foreach($matches[1] as $key => $pattern)
69
+		foreach ($matches[1] as $key => $pattern)
70 70
 		{
71 71
 			$full_pattern = $matches[0][$key];
72 72
 			$what = $matches[2][$key];
@@ -75,25 +75,25 @@  discard block
 block discarded – undo
75 75
 			if (preg_quote($pattern) == $pattern)
76 76
 			{
77 77
 
78
-				$replace[$full_pattern] = (strpos($full_pattern,'eregi')!==false?'strposi':'strpos').'('.$what.','.$pattern.
79
-					') '.($full_pattern[0]=='!'?'===':'!==').' false'.$matches[4][$key];
78
+				$replace[$full_pattern] = (strpos($full_pattern, 'eregi') !== false ? 'strposi' : 'strpos').'('.$what.','.$pattern.
79
+					') '.($full_pattern[0] == '!' ? '===' : '!==').' false'.$matches[4][$key];
80 80
 			}
81 81
 			else
82 82
 			{
83 83
 				// full ereg regular expression --> preg_match
84
-				$preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'");
85
-				$replace[$full_pattern] = str_replace(array('eregi','ereg',$pattern),array('preg_match','preg_match',$preg_pattern),$full_pattern);
84
+				$preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'");
85
+				$replace[$full_pattern] = str_replace(array('eregi', 'ereg', $pattern), array('preg_match', 'preg_match', $preg_pattern), $full_pattern);
86 86
 			}
87 87
 		}
88 88
 		//print_r($replace);
89
-		$lines = strtr($lines,$replace);
89
+		$lines = strtr($lines, $replace);
90 90
 	}
91 91
 	// PHP Deprecated:  Function ereg_replace() is deprecated
92
-	if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m',$lines,$matches))
92
+	if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m', $lines, $matches))
93 93
 	{
94 94
 		$replace = array();
95 95
 		//print_r($matches);
96
-		foreach($matches[1] as $key => $pattern)
96
+		foreach ($matches[1] as $key => $pattern)
97 97
 		{
98 98
 			$full_pattern = $matches[0][$key];
99 99
 			$other = $matches[2][$key];
@@ -101,41 +101,41 @@  discard block
 block discarded – undo
101 101
 			// simple replace --> use str_replace()
102 102
 			if (preg_quote($pattern) == $pattern)
103 103
 			{
104
-				$replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace'),array('stri_replace','str_replace'),$full_pattern);
104
+				$replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace'), array('stri_replace', 'str_replace'), $full_pattern);
105 105
 			}
106 106
 			else
107 107
 			{
108 108
 				// full ereg regular expression --> preg_replace
109
-				$preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'");
110
-				$replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace',$pattern),
111
-					array('preg_replace','preg_replace',$preg_pattern),$full_pattern);
109
+				$preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'");
110
+				$replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace', $pattern),
111
+					array('preg_replace', 'preg_replace', $preg_pattern), $full_pattern);
112 112
 			}
113 113
 		}
114 114
 		//print_r($replace);
115
-		$lines = strtr($lines,$replace);
115
+		$lines = strtr($lines, $replace);
116 116
 	}
117 117
 	// remove extra '/' from regular expressions
118
-	$lines = str_replace(array("'/'.'","'.'/'","'.'/i'"),array("'/","/'","/i'"),$lines);
118
+	$lines = str_replace(array("'/'.'", "'.'/'", "'.'/i'"), array("'/", "/'", "/i'"), $lines);
119 119
 
120 120
 	// fix call to not longer existing PDO method $result->fetchSingle()
121
-	$lines = str_replace('->fetchSingle(','->fetchColumn(',$lines);
121
+	$lines = str_replace('->fetchSingle(', '->fetchColumn(', $lines);
122 122
 
123 123
 	// fix calls to deprecated call_user_method(_array)?(method,object[,args])
124
-	if (preg_match('/call_user_method(_array)?\(/',$lines,$matches))
124
+	if (preg_match('/call_user_method(_array)?\(/', $lines, $matches))
125 125
 	{
126
-		$lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/','call_user_func(array(\\2,\\1)\\3',$lines);
127
-		$lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/','call_user_func_array(array(\\2,\\1)\\3',$lines);
126
+		$lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/', 'call_user_func(array(\\2,\\1)\\3', $lines);
127
+		$lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/', 'call_user_func_array(array(\\2,\\1)\\3', $lines);
128 128
 	}
129 129
 
130 130
 	if ($lines != $orig)
131 131
 	{
132
-		file_put_contents($file.'53',$lines);
133
-		system('/usr/bin/php -l '.$file.'53',$ret);
132
+		file_put_contents($file.'53', $lines);
133
+		system('/usr/bin/php -l '.$file.'53', $ret);
134 134
 		system('/usr/bin/diff -u '.$file.' '.$file.'53');
135 135
 		if (!$ret && $replace_file)
136 136
 		{
137 137
 			unlink($file);
138
-			rename($file.'53',$file);
138
+			rename($file.'53', $file);
139 139
 		}
140 140
 		return !$ret;
141 141
 	}
@@ -149,25 +149,25 @@  discard block
 block discarded – undo
149 149
  * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
150 150
  * @return boolean false on error
151 151
  */
152
-function fix_depricated_recursive($dir,$replace_file=false)
152
+function fix_depricated_recursive($dir, $replace_file = false)
153 153
 {
154 154
 	if (!is_dir($dir)) return false;
155 155
 
156
-	foreach(scandir($dir) as $file)
156
+	foreach (scandir($dir) as $file)
157 157
 	{
158 158
 		if ($file == '.' || $file == '..') continue;
159 159
 
160 160
 		if (is_dir($dir.'/'.$file))
161 161
 		{
162
-			fix_depricated_recursive($dir.'/'.$file,$replace_file);
162
+			fix_depricated_recursive($dir.'/'.$file, $replace_file);
163 163
 		}
164
-		elseif(substr($file,-4) == '.php')
164
+		elseif (substr($file, -4) == '.php')
165 165
 		{
166
-			echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': ';
167
-			fix_depricated($dir.'/'.$file,$replace_file);
166
+			echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': ';
167
+			fix_depricated($dir.'/'.$file, $replace_file);
168 168
 		}
169 169
 	}
170
-	echo "\r".str_repeat(' ',100)."\r";
170
+	echo "\r".str_repeat(' ', 100)."\r";
171 171
 	return true;
172 172
 }
173 173
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @param string $error=null
178 178
  */
179
-function usage($error=null)
179
+function usage($error = null)
180 180
 {
181 181
 	global $prog;
182 182
 	echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n";
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 if (!$args) usage();
191 191
 
192 192
 $replace_file = false;
193
-while(($arg = array_shift($args)))
193
+while (($arg = array_shift($args)))
194 194
 {
195
-	switch($arg)
195
+	switch ($arg)
196 196
 	{
197 197
 		case '-h':
198 198
 		case '--help':
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 if (!is_dir($arg))
218 218
 {
219
-	fix_depricated($arg,$replace_file);
219
+	fix_depricated($arg, $replace_file);
220 220
 }
221 221
 else
222 222
 {
223
-	fix_depricated_recursive($arg,$replace_file);
223
+	fix_depricated_recursive($arg, $replace_file);
224 224
 }
225 225
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +41 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,10 +14,13 @@  discard block
 block discarded – undo
14 14
  * @version $Id$
15 15
  */
16 16
 
17
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling as web-page
17
+if (php_sapi_name() !== 'cli')
18
+{
19
+	// security precaution: forbit calling as web-page
18 20
 {
19 21
 	die('<h1>fix_depricated.php must NOT be called as web-page --> exiting !!!</h1>');
20 22
 }
23
+}
21 24
 
22 25
 /**
23 26
  * Fix depricated stuff in a given file
@@ -29,9 +32,16 @@  discard block
 block discarded – undo
29 32
 function fix_depricated($file,$replace_file=false)
30 33
 {
31 34
 	$orig = $lines = file_get_contents($file);
32
-	if ($lines === false) return false;
35
+	if ($lines === false)
36
+	{
37
+		return false;
38
+	}
33 39
 	global $prog;
34
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
40
+	if (basename($file) == $prog)
41
+	{
42
+		return true;
43
+	}
44
+	// dont fix ourself ;-)
35 45
 
36 46
 	// PHP Deprecated:  Assigning the return value of new by reference is deprecated
37 47
 	if (preg_match('/= *& *new /m',$lines))
@@ -54,7 +64,10 @@  discard block
 block discarded – undo
54 64
 			else
55 65
 			{
56 66
 				$preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0];
57
-				if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
67
+				if (strpos($full_pattern,'spliti'))
68
+				{
69
+					$preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
70
+				}
58 71
 				$replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern);
59 72
 			}
60 73
 		}
@@ -151,11 +164,17 @@  discard block
 block discarded – undo
151 164
  */
152 165
 function fix_depricated_recursive($dir,$replace_file=false)
153 166
 {
154
-	if (!is_dir($dir)) return false;
167
+	if (!is_dir($dir))
168
+	{
169
+		return false;
170
+	}
155 171
 
156 172
 	foreach(scandir($dir) as $file)
157 173
 	{
158
-		if ($file == '.' || $file == '..') continue;
174
+		if ($file == '.' || $file == '..')
175
+		{
176
+			continue;
177
+		}
159 178
 
160 179
 		if (is_dir($dir.'/'.$file))
161 180
 		{
@@ -180,14 +199,20 @@  discard block
 block discarded – undo
180 199
 {
181 200
 	global $prog;
182 201
 	echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n";
183
-	if ($error) echo $error."\n\n";
202
+	if ($error)
203
+	{
204
+		echo $error."\n\n";
205
+	}
184 206
 	exit($error ? 1 : 0);
185 207
 }
186 208
 
187 209
 $args = $_SERVER['argv'];
188 210
 $prog = basename(array_shift($args));
189 211
 
190
-if (!$args) usage();
212
+if (!$args)
213
+{
214
+	usage();
215
+}
191 216
 
192 217
 $replace_file = false;
193 218
 while(($arg = array_shift($args)))
@@ -204,15 +229,21 @@  discard block
 block discarded – undo
204 229
 			break;
205 230
 
206 231
 		default:
207
-			if ($args)	// not last argument
232
+			if ($args)
233
+			{
234
+				// not last argument
208 235
 			{
209 236
 				usage("Unknown argument '$arg'!");
210 237
 			}
238
+			}
211 239
 			break 2;
212 240
 	}
213 241
 }
214 242
 
215
-if (!file_exists($arg)) usage("Error: $arg not found!");
243
+if (!file_exists($arg))
244
+{
245
+	usage("Error: $arg not found!");
246
+}
216 247
 
217 248
 if (!is_dir($arg))
218 249
 {
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   +85 added lines, -88 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	'php'         => PHP_BINARY,
18 18
 	'source_dir'  => realpath(__DIR__.'/../..'),
19 19
 	'data_dir'    => '/var/lib/egroupware',
20
-	'header'      => '$data_dir/header.inc.php',	// symlinked to source_dir by rpm
20
+	'header'      => '$data_dir/header.inc.php', // symlinked to source_dir by rpm
21 21
 	'setup-cli'   => '$source_dir/setup/setup-cli.php',
22 22
 	'domain'      => 'default',
23 23
 	'config_user' => 'admin',
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	'db_user'     => 'egroupware',
30 30
 	'db_pass'     => randomstring(),
31 31
 	'db_grant_host' => 'localhost',
32
-	'db_root'     => 'root',	// mysql root user/pw to create database
32
+	'db_root'     => 'root', // mysql root user/pw to create database
33 33
 	'db_root_pw'  => '',
34 34
 	'backup'      => '',
35 35
 	'admin_user'  => 'sysop',
36 36
 	'admin_passwd'=> randomstring(),
37 37
 	'admin_email' => '',
38
-	'lang'        => 'en',	// languages for admin user and extra lang to install
38
+	'lang'        => 'en', // languages for admin user and extra lang to install
39 39
 	'charset'     => 'utf-8',
40 40
 	'start_db'    => '/sbin/service mysqld',
41 41
 	'autostart_db' => '/sbin/chkconfig --level 345 mysqld on',
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	'ldap_search_filter' => '(uid=%user)',
56 56
 	'ldap_group_context' => 'ou=groups,$base',
57 57
 	'ldap_encryption_type' => '',
58
-	'sambaadmin/sambasid'=> '',	// SID for sambaadmin
58
+	'sambaadmin/sambasid'=> '', // SID for sambaadmin
59 59
 	'mailserver'    => '',
60 60
 	'smtpserver'    => 'localhost,25',
61
-	'smtp'          => '',	// see setup-cli.php --help config
61
+	'smtp'          => '', // see setup-cli.php --help config
62 62
 	'imap'          => '',
63 63
 	'sieve'         => '',
64 64
 	'folder'        => '',
65
-	'install-update-app' => '',	// install or update a single (non-default) app
66
-	'webserver_user'=> 'apache',	// required to fix permissions
65
+	'install-update-app' => '', // install or update a single (non-default) app
66
+	'webserver_user'=> 'apache', // required to fix permissions
67 67
 	'apache_config'   => '/etc/httpd/conf.d/egroupware.conf',
68 68
 	'php5enmod'     => '',
69 69
 );
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
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,25 +85,22 @@  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 93
 		$matches = null;
94 94
 		// check for ID in /etc/os-release and use it
95
-		if (file_exists('/etc/os-release') && preg_match('/^ID="?([^"=]+)"?$/m', $os_release=file_get_contents('/etc/os-release'), $matches))
95
+		if (file_exists('/etc/os-release') && preg_match('/^ID="?([^"=]+)"?$/m', $os_release = file_get_contents('/etc/os-release'), $matches))
96 96
 		{
97 97
 			$distro = $matches[1];
98 98
 		}
99 99
 		// old detections based on distro specific /etc/*release files
100 100
 		else
101 101
 		{
102
-			$distro = file_exists('/etc/SuSE-release') ? 'suse' :
103
-				(file_exists('/etc/mandriva-release') ? 'mandriva' :
104
-				(file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
105
-					file_get_contents('/etc/lsb-release')) ? 'univention' :
106
-				(file_exists('/etc/debian_version') ? 'debian' : 'rh')));
102
+			$distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
103
+					file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh')));
107 104
 		}
108 105
 	}
109 106
 	switch (($config['distro'] = $distro))
@@ -175,9 +172,9 @@  discard block
 block discarded – undo
175 172
 			}
176 173
 			elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql'))
177 174
 			{
178
-				foreach(array('start_db','autostart_db') as $name)
175
+				foreach (array('start_db', 'autostart_db') as $name)
179 176
 				{
180
-					$config[$name] = str_replace('mysqld','mysql',$config[$name]);
177
+					$config[$name] = str_replace('mysqld', 'mysql', $config[$name]);
181 178
 				}
182 179
 			}
183 180
 			break;
@@ -193,48 +190,48 @@  discard block
 block discarded – undo
193 190
 if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL']))
194 191
 {
195 192
 	$conf = array();
196
-	$config_set = preg_split('/[ \t]+/',trim($config_set));
197
-	while($config_set)
193
+	$config_set = preg_split('/[ \t]+/', trim($config_set));
194
+	while ($config_set)
198 195
 	{
199 196
 		$val = array_shift($config_set);
200 197
 		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
201 198
 		{
202
-			while (substr($val,-1) != $quote)
199
+			while (substr($val, -1) != $quote)
203 200
 			{
204 201
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
205 202
 				$val .= ' '.array_shift($config_set);
206 203
 			}
207
-			$val = substr($val,1,-1);
204
+			$val = substr($val, 1, -1);
208 205
 		}
209 206
 		$conf[] = $val;
210 207
 	}
211
-	$argv = array_merge($conf,$argv);
208
+	$argv = array_merge($conf, $argv);
212 209
 }
213 210
 
214 211
 $auth_type_given = false;
215
-while(($arg = array_shift($argv)))
212
+while (($arg = array_shift($argv)))
216 213
 {
217 214
 	if ($arg == '-v' || $arg == '--verbose')
218 215
 	{
219 216
 		$verbose = true;
220 217
 	}
221
-	elseif($arg == '-h' || $arg == '--help')
218
+	elseif ($arg == '-h' || $arg == '--help')
222 219
 	{
223 220
 		usage();
224 221
 	}
225
-	elseif($arg == '--suse')
222
+	elseif ($arg == '--suse')
226 223
 	{
227 224
 		set_distro_defaults('suse');
228 225
 	}
229
-	elseif($arg == '--distro')
226
+	elseif ($arg == '--distro')
230 227
 	{
231 228
 		set_distro_defaults(array_shift($argv));
232 229
 	}
233
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
230
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
234 231
 	{
235 232
 		$config[$name] = array_shift($argv);
236 233
 
237
-		switch($name)
234
+		switch ($name)
238 235
 		{
239 236
 			case 'auth_type':
240 237
 				$auth_type_given = true;
@@ -255,18 +252,18 @@  discard block
 block discarded – undo
255 252
 }
256 253
 
257 254
 $replace = array();
258
-foreach($config as $name => $value)
255
+foreach ($config as $name => $value)
259 256
 {
260 257
 	$replace['$'.$name] = $value;
261
-	if (strpos($value,'$') !== false)
258
+	if (strpos($value, '$') !== false)
262 259
 	{
263
-		$config[$name] = strtr($value,$replace);
260
+		$config[$name] = strtr($value, $replace);
264 261
 	}
265 262
 }
266 263
 // basic config checks
267
-foreach(array('php','source_dir','data_dir','setup-cli') as $name)
264
+foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name)
268 265
 {
269
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
266
+	if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!');
270 267
 }
271 268
 
272 269
 // fix important php.ini and conf.d/*.ini settings
@@ -281,13 +278,13 @@  discard block
 block discarded – undo
281 278
 	$GLOBALS['egw_info'] = array(
282 279
 		'flags' => array(
283 280
 			'noapi' => true,
284
-			'currentapp' => 'login',	// stop PHP Notice: Undefined index "currentapp" in pre 16.1 header
281
+			'currentapp' => 'login', // stop PHP Notice: Undefined index "currentapp" in pre 16.1 header
285 282
 		)
286 283
 	);
287 284
 	include $config['header'];
288 285
 
289 286
 	// get user from header and replace password, as we dont know it
290
-	$old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']);
287
+	$old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']);
291 288
 	// register a shutdown function to put old password back in any case
292 289
 	register_shutdown_function(function() use (&$config, $old_password)
293 290
 	{
@@ -295,7 +292,7 @@  discard block
 block discarded – undo
295 292
 	});
296 293
 }
297 294
 // new header or does not include requested domain (!= "default") --> new install
298
-if (!isset($GLOBALS['egw_domain']) ||  $config['domain'] !== 'default' && !isset($GLOBALS['egw_domain'][$config['domain']]))
295
+if (!isset($GLOBALS['egw_domain']) || $config['domain'] !== 'default' && !isset($GLOBALS['egw_domain'][$config['domain']]))
299 296
 {
300 297
 	// --> new install
301 298
 	$extra_config = '';
@@ -312,7 +309,7 @@  discard block
 block discarded – undo
312 309
 	}
313 310
 	// create database
314 311
 	$setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db';
315
-	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)
312
+	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)
316 313
 	{
317 314
 		$setup_db .= ' '.escapeshellarg($name.'='.$config[$name]);
318 315
 	}
@@ -320,7 +317,7 @@  discard block
 block discarded – undo
320 317
 
321 318
 	// check if ldap is required and initialise it
322 319
 	// we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql!
323
-	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
320
+	@list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3);
324 321
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
325 322
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
326 323
 	if (empty($rest)) unset($config['account-auth']);
@@ -331,15 +328,15 @@  discard block
 block discarded – undo
331 328
 
332 329
 		$setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='.
333 330
 			($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap');
334
-		foreach(array(
335
-			'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw',	// non-egw params: only used for create
336
-			'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context',	// egw params
331
+		foreach (array(
332
+			'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create
333
+			'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params
337 334
 			'ldap_encryption_type', 'sambaadmin/sambasid',
338 335
 		) as $name)
339 336
 		{
340
-			if (strpos($value=$config[$name],'$') !== false)
337
+			if (strpos($value = $config[$name], '$') !== false)
341 338
 			{
342
-				$config[$name] = $value = strtr($value,array(
339
+				$config[$name] = $value = strtr($value, array(
343 340
 					'$suffix' => $config['ldap_suffix'],
344 341
 					'$base' => $config['ldap_base'],
345 342
 					'$admin_pw' => $config['ldap_admin_pw'],
@@ -347,7 +344,7 @@  discard block
 block discarded – undo
347 344
 			}
348 345
 			$setup_ldap .= ' '.escapeshellarg($name.'='.$value);
349 346
 
350
-			if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw')))
347
+			if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw')))
351 348
 			{
352 349
 				$extra_config .= ' '.escapeshellarg($name.'='.$value);
353 350
 			}
@@ -381,7 +378,7 @@  discard block
 block discarded – undo
381 378
 	}
382 379
 	// create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error)
383 380
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
384
-	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
381
+	foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name)
385 382
 	{
386 383
 		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
387 384
 	}
@@ -395,7 +392,7 @@  discard block
 block discarded – undo
395 392
 	// check if webserver is started and start it (permanent) if not
396 393
 	if ($config['start_webserver'])
397 394
 	{
398
-		exec(build_cmd('start_webserver', 'status'),$dummy,$ret);
395
+		exec(build_cmd('start_webserver', 'status'), $dummy, $ret);
399 396
 		if ($ret)
400 397
 		{
401 398
 			system(build_cmd('start_webserver', 'start'));
@@ -437,18 +434,18 @@  discard block
 block discarded – undo
437 434
 	// update egroupware, or single app(s), in later case skip backup
438 435
 	$setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd'].
439 436
 		(empty($config['install-update-app']) ? '' : ',no,'.$config['install-update-app']));
440
-	$ret = run_cmd($setup_update,$output,array(4,15));
437
+	$ret = run_cmd($setup_update, $output, array(4, 15));
441 438
 
442
-	switch($ret)
439
+	switch ($ret)
443 440
 	{
444 441
 		case 4:		// header needs an update
445 442
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
446 443
 			run_cmd($header_update);
447
-			$ret = run_cmd($setup_update,$output,15);
444
+			$ret = run_cmd($setup_update, $output, 15);
448 445
 			if ($ret != 15) break;
449 446
 			// fall through
450 447
 		case 15:	// missing configuration (eg. mailserver)
451
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
448
+			if (!$verbose) echo implode("\n", (array)$output)."\n";
452 449
 			break;
453 450
 
454 451
 		case 0:
@@ -493,18 +490,18 @@  discard block
 block discarded – undo
493 490
  * @param string $password new password
494 491
  * @return string old password
495 492
  */
496
-function patch_header($filename,&$user,$password)
493
+function patch_header($filename, &$user, $password)
497 494
 {
498 495
 	$header = file_get_contents($filename);
499 496
 
500 497
 	$umatches = $pmatches = null;
501
-	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) ||
502
-		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches))
498
+	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) ||
499
+		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches))
503 500
 	{
504
-		bail_out(99,"$filename is no regular EGroupware header.inc.php!");
501
+		bail_out(99, "$filename is no regular EGroupware header.inc.php!");
505 502
 	}
506
-	file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
507
-		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header));
503
+	file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
504
+		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header));
508 505
 
509 506
 	$user = $umatches[1];
510 507
 
@@ -519,7 +516,7 @@  discard block
 block discarded – undo
519 516
  * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
520 517
  * @return int exit code of $cmd
521 518
  */
522
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
519
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
523 520
 {
524 521
 	global $verbose;
525 522
 
@@ -527,16 +524,16 @@  discard block
 block discarded – undo
527 524
 	{
528 525
 		echo $cmd."\n";
529 526
 		$ret = null;
530
-		system($cmd,$ret);
527
+		system($cmd, $ret);
531 528
 	}
532 529
 	else
533 530
 	{
534 531
 		$output[] = $cmd;
535
-		exec($cmd,$output,$ret);
532
+		exec($cmd, $output, $ret);
536 533
 	}
537
-	if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout))
534
+	if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout))
538 535
 	{
539
-		bail_out($ret,$verbose?null:$output);
536
+		bail_out($ret, $verbose ?null:$output);
540 537
 	}
541 538
 	return $ret;
542 539
 }
@@ -547,9 +544,9 @@  discard block
 block discarded – undo
547 544
  * @param int $ret =1
548 545
  * @param array|string $output line(s) to output before temination notice
549 546
  */
550
-function bail_out($ret=1,$output=null)
547
+function bail_out($ret = 1, $output = null)
551 548
 {
552
-	if ($output) echo implode("\n",(array)$output);
549
+	if ($output) echo implode("\n", (array)$output);
553 550
 	echo "\n\nInstallation failed --> exiting!\n\n";
554 551
 	exit($ret);
555 552
 }
@@ -560,24 +557,24 @@  discard block
 block discarded – undo
560 557
  * @param int $len =16
561 558
  * @return string
562 559
  */
563
-function randomstring($len=16)
560
+function randomstring($len = 16)
564 561
 {
565 562
 	static $usedchars = array(
566
-		'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
567
-		'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
568
-		'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
569
-		'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
570
-		'@','!','&','(',')','=','?',';',':','#','_','-','<',
571
-		'>','|','[',']','}',	// dont add %, /\,'"{ as we have problems dealing with them
563
+		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
564
+		'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
565
+		'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
566
+		'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
567
+		'@', '!', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<',
568
+		'>', '|', '[', ']', '}', // dont add %, /\,'"{ as we have problems dealing with them
572 569
 	);
573 570
 
574 571
 	// use cryptographically secure random_int available in PHP 7+
575 572
 	$func = function_exists('random_int') ? 'random_int' : 'mt_rand';
576 573
 
577 574
 	$str = '';
578
-	for($i=0; $i < $len; $i++)
575
+	for ($i = 0; $i < $len; $i++)
579 576
 	{
580
-		$str .= $usedchars[$func(0,count($usedchars)-1)];
577
+		$str .= $usedchars[$func(0, count($usedchars) - 1)];
581 578
 	}
582 579
 	return $str;
583 580
 }
@@ -587,20 +584,20 @@  discard block
 block discarded – undo
587 584
  *
588 585
  * @param string $error =null optional error-message
589 586
  */
590
-function usage($error=null)
587
+function usage($error = null)
591 588
 {
592
-	global $prog,$config;
589
+	global $prog, $config;
593 590
 
594 591
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n";
595 592
 	echo "options and their defaults:\n";
596
-	foreach($config as $name => $default)
593
+	foreach ($config as $name => $default)
597 594
 	{
598
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
599
-		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
595
+		if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options
596
+		if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16)
600 597
 		{
601 598
 			$default = '<16 char random string>';
602 599
 		}
603
-		echo '--'.str_pad($name,20).$default."\n";
600
+		echo '--'.str_pad($name, 20).$default."\n";
604 601
 	}
605 602
 	if ($error)
606 603
 	{
@@ -655,8 +652,8 @@  discard block
 block discarded – undo
655 652
 	$config['distro'] = 'univention';
656 653
 
657 654
 	// set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment
658
-	@list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
659
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
655
+	@list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
656
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
660 657
 	{
661 658
 		$lang .= '-'.strtolower($nat);
662 659
 	}
@@ -681,7 +678,7 @@  discard block
 block discarded – undo
681 678
 		// ldap password hash (our default blowfish_crypt seems not to work)
682 679
 		$config['ldap_encryption_type'] = 'sha512_crypt';
683 680
 
684
-		$config['account_min_id'] = 1200;	// UCS use 11xx for internal users/groups
681
+		$config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups
685 682
 
686 683
 		$config['account-auth'] = 'univention,univention';
687 684
 
@@ -691,7 +688,7 @@  discard block
 block discarded – undo
691 688
 		// mailserver, see setup-cli.php --help config
692 689
 		if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) &&
693 690
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
694
-			($domains=_ucr_get('mail/hosteddomains')))
691
+			($domains = _ucr_get('mail/hosteddomains')))
695 692
 		{
696 693
 			if (!is_array($domains)) $domains = explode("\n", $domains);
697 694
 			$domain = array_shift($domains);
@@ -738,12 +735,12 @@  discard block
 block discarded – undo
738 735
  */
739 736
 function _ucr_get($name)
740 737
 {
741
-	static $values=null;
738
+	static $values = null;
742 739
 	if (!isset($values))
743 740
 	{
744 741
 		$output = $matches = null;
745 742
 		exec('/usr/sbin/ucr dump', $output);
746
-		foreach($output as $line)
743
+		foreach ($output as $line)
747 744
 		{
748 745
 			if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches))
749 746
 			{
@@ -829,7 +826,7 @@  discard block
 block discarded – undo
829 826
 		file_exists($default_cert_dir = $locations['default_cert_dir']))
830 827
 	{
831 828
 		$check_dirs = array($default_cert_dir);
832
-		foreach(scandir($default_cert_dir) as $cert)
829
+		foreach (scandir($default_cert_dir) as $cert)
833 830
 		{
834 831
 			$cert = $default_cert_dir.'/'.$cert;
835 832
 			if (is_link($cert) && ($link = readlink($cert)) &&
@@ -846,7 +843,7 @@  discard block
 block discarded – undo
846 843
 			//echo "$config[apache_config] contains open_basedir $matches[1]\n";
847 844
 			$open_basedirs = explode(':', $matches[1]);
848 845
 			$need_adding = array();
849
-			foreach($check_dirs as $dir)
846
+			foreach ($check_dirs as $dir)
850 847
 			{
851 848
 				if (!in_array($dir, $open_basedirs)) $need_adding[] = $dir;
852 849
 			}
@@ -875,7 +872,7 @@  discard block
 block discarded – undo
875 872
 function _size_with_unit($_size)
876 873
 {
877 874
 	$size = (int)$_size;
878
-	switch(strtoupper(substr($_size, -1)))
875
+	switch (strtoupper(substr($_size, -1)))
879 876
 	{
880 877
 		case 'G':
881 878
 			$size *= 1024;
Please login to merge, or discard this patch.
Braces   +94 added lines, -24 removed lines patch added patch discarded remove patch
@@ -8,10 +8,13 @@  discard block
 block discarded – undo
8 8
  * @author [email protected]
9 9
  */
10 10
 
11
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling post_install as web-page
11
+if (php_sapi_name() !== 'cli')
12
+{
13
+	// security precaution: forbit calling post_install as web-page
12 14
 {
13 15
 	die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>');
14 16
 }
17
+}
15 18
 $verbose = false;
16 19
 $config = array(
17 20
 	'php'         => PHP_BINARY,
@@ -110,8 +113,14 @@  discard block
 block discarded – undo
110 113
 	{
111 114
 		case 'suse': case 'opensuse-leap': case 'opensuse':
112 115
 			// openSUSE 12.1+ no longer uses php5
113
-			if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5';
114
-			if (file_exists('/usr/bin/php7')) $config['php'] = '/usr/bin/php7';
116
+			if (file_exists('/usr/bin/php5'))
117
+			{
118
+				$config['php'] = '/usr/bin/php5';
119
+			}
120
+			if (file_exists('/usr/bin/php7'))
121
+			{
122
+				$config['php'] = '/usr/bin/php7';
123
+			}
115 124
 			$config['start_db'] = '/sbin/service mysql';
116 125
 			$config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on';
117 126
 			$config['start_webserver'] = '/sbin/service apache2';
@@ -166,9 +175,12 @@  discard block
 block discarded – undo
166 175
 			// fall through
167 176
 		case 'rh': case 'rhel': case 'centos': case 'fedora':
168 177
 			// some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld"
169
-			if (file_exists('/usr/bin/systemctl'))	// RHEL 7
178
+			if (file_exists('/usr/bin/systemctl'))
179
+			{
180
+				// RHEL 7
170 181
 			{
171 182
 				$config['start_db'] = '/usr/bin/systemctl %s mariadb';
183
+			}
172 184
 				$config['autostart_db'] = build_cmd('start_db', 'enable');
173 185
 				$config['start_webserver'] = '/usr/bin/systemctl %s httpd';
174 186
 				$config['autostart_webserver'] = build_cmd('start_webserver', 'enable');
@@ -197,11 +209,14 @@  discard block
 block discarded – undo
197 209
 	while($config_set)
198 210
 	{
199 211
 		$val = array_shift($config_set);
200
-		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
212
+		if (($quote = $val[0]) == "'" || $quote == '"')
213
+		{
214
+			// arguments might be quoted with ' or "
201 215
 		{
202 216
 			while (substr($val,-1) != $quote)
203 217
 			{
204 218
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
219
+		}
205 220
 				$val .= ' '.array_shift($config_set);
206 221
 			}
207 222
 			$val = substr($val,1,-1);
@@ -266,8 +281,11 @@  discard block
 block discarded – undo
266 281
 // basic config checks
267 282
 foreach(array('php','source_dir','data_dir','setup-cli') as $name)
268 283
 {
269
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
270
-}
284
+	if (!file_exists($config[$name]))
285
+	{
286
+		bail_out(1,$config[$name].' not found!');
287
+	}
288
+	}
271 289
 
272 290
 // fix important php.ini and conf.d/*.ini settings
273 291
 check_fix_php_apc_ini();
@@ -276,7 +294,9 @@  discard block
 block discarded – undo
276 294
 $setup_cli = $config['php'].' -d memory_limit=-1 '.$config['setup-cli'];
277 295
 
278 296
 // if we have a header, include it
279
-if (file_exists($config['header']) && filesize($config['header']) >= 200)	// default header redirecting to setup is 147 bytes
297
+if (file_exists($config['header']) && filesize($config['header']) >= 200)
298
+{
299
+	// default header redirecting to setup is 147 bytes
280 300
 {
281 301
 	$GLOBALS['egw_info'] = array(
282 302
 		'flags' => array(
@@ -284,6 +304,7 @@  discard block
 block discarded – undo
284 304
 			'currentapp' => 'login',	// stop PHP Notice: Undefined index "currentapp" in pre 16.1 header
285 305
 		)
286 306
 	);
307
+}
287 308
 	include $config['header'];
288 309
 
289 310
 	// get user from header and replace password, as we dont know it
@@ -307,7 +328,10 @@  discard block
 block discarded – undo
307 328
 		if ($ret)
308 329
 		{
309 330
 			system(build_cmd('start_db', 'start'));
310
-			if (!empty($config['autostart_db'])) system($config['autostart_db']);
331
+			if (!empty($config['autostart_db']))
332
+			{
333
+				system($config['autostart_db']);
334
+			}
311 335
 		}
312 336
 	}
313 337
 	// create database
@@ -323,7 +347,10 @@  discard block
 block discarded – undo
323 347
 	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
324 348
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
325 349
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
326
-	if (empty($rest)) unset($config['account-auth']);
350
+	if (empty($rest))
351
+	{
352
+		unset($config['account-auth']);
353
+	}
327 354
 	if (array_intersect(array($config['account_repository'], $config['auth_type']), array('ldap', 'univention')))
328 355
 	{
329 356
 		// set account_min_id to 1100 if not specified to NOT clash with system accounts
@@ -383,7 +410,10 @@  discard block
 block discarded – undo
383 410
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
384 411
 	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
385 412
 	{
386
-		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
413
+		if (!empty($config[$name]))
414
+		{
415
+			$setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
416
+		}
387 417
 	}
388 418
 	run_cmd($setup_mailserver);
389 419
 
@@ -399,7 +429,10 @@  discard block
 block discarded – undo
399 429
 		if ($ret)
400 430
 		{
401 431
 			system(build_cmd('start_webserver', 'start'));
402
-			if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']);
432
+			if (!empty($config['autostart_webserver']))
433
+			{
434
+				system($config['autostart_webserver']);
435
+			}
403 436
 		}
404 437
 		else
405 438
 		{
@@ -445,10 +478,16 @@  discard block
 block discarded – undo
445 478
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
446 479
 			run_cmd($header_update);
447 480
 			$ret = run_cmd($setup_update,$output,15);
448
-			if ($ret != 15) break;
481
+			if ($ret != 15)
482
+			{
483
+				break;
484
+			}
449 485
 			// fall through
450 486
 		case 15:	// missing configuration (eg. mailserver)
451
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
487
+			if (!$verbose)
488
+			{
489
+				echo implode("\n",(array)$output)."\n";
490
+			}
452 491
 			break;
453 492
 
454 493
 		case 0:
@@ -478,9 +517,15 @@  discard block
 block discarded – undo
478 517
 {
479 518
 	global $config;
480 519
 
481
-	if (isset($config[$cmd])) $cmd = $config[$cmd];
520
+	if (isset($config[$cmd]))
521
+	{
522
+		$cmd = $config[$cmd];
523
+	}
482 524
 
483
-	if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd);
525
+	if (strpos($cmd, '%s'))
526
+	{
527
+		return str_replace('%s', $arg, $cmd);
528
+	}
484 529
 
485 530
 	return $cmd.' '.$arg;
486 531
 }
@@ -549,7 +594,10 @@  discard block
 block discarded – undo
549 594
  */
550 595
 function bail_out($ret=1,$output=null)
551 596
 {
552
-	if ($output) echo implode("\n",(array)$output);
597
+	if ($output)
598
+	{
599
+		echo implode("\n",(array)$output);
600
+	}
553 601
 	echo "\n\nInstallation failed --> exiting!\n\n";
554 602
 	exit($ret);
555 603
 }
@@ -595,7 +643,11 @@  discard block
 block discarded – undo
595 643
 	echo "options and their defaults:\n";
596 644
 	foreach($config as $name => $default)
597 645
 	{
598
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
646
+		if (in_array($name, array('postfix','cyrus')))
647
+		{
648
+			continue;
649
+		}
650
+		// do NOT report deprecated options
599 651
 		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
600 652
 		{
601 653
 			$default = '<16 char random string>';
@@ -693,7 +745,10 @@  discard block
 block discarded – undo
693 745
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
694 746
 			($domains=_ucr_get('mail/hosteddomains')))
695 747
 		{
696
-			if (!is_array($domains)) $domains = explode("\n", $domains);
748
+			if (!is_array($domains))
749
+			{
750
+				$domains = explode("\n", $domains);
751
+			}
697 752
 			$domain = array_shift($domains);
698 753
 			// set "use auth with session credentials",tls,"not user editable","further identities"
699 754
 			$config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes";
@@ -712,13 +767,19 @@  discard block
 block discarded – undo
712 767
 					$config['imap'] = ',,Imap\\Dovecot';
713 768
 				}
714 769
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
715
-				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190;
770
+				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port')))
771
+				{
772
+					$sieve_port = 4190;
773
+				}
716 774
 			}
717 775
 			else
718 776
 			{
719 777
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus';
720 778
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
721
-				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190;
779
+				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port')))
780
+				{
781
+					$sieve_port = 4190;
782
+				}
722 783
 			}
723 784
 			// set folders so mail creates them on first login, UCS does not automatic
724 785
 			$config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,Spam,,Ham';
@@ -781,7 +842,10 @@  discard block
 block discarded – undo
781 842
 		$shm_size = ini_get('apc.shm_size');
782 843
 		$shm_segments = ini_get('apc.shm_segments');
783 844
 		// ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit
784
-		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M';
845
+		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576))
846
+		{
847
+			$shm_size .= 'M';
848
+		}
785 849
 
786 850
 		$size = _size_with_unit($shm_size) * $shm_segments;
787 851
 		//echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n";
@@ -797,7 +861,10 @@  discard block
 block discarded – undo
797 861
 				file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path)))
798 862
 			{
799 863
 				$new_shm_size = 128 / $shm_segments;
800
-				if (!$numeric_size) $new_shm_size .= 'M';
864
+				if (!$numeric_size)
865
+				{
866
+					$new_shm_size .= 'M';
867
+				}
801 868
 				if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini))
802 869
 				{
803 870
 					file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini));
@@ -848,7 +915,10 @@  discard block
 block discarded – undo
848 915
 			$need_adding = array();
849 916
 			foreach($check_dirs as $dir)
850 917
 			{
851
-				if (!in_array($dir, $open_basedirs)) $need_adding[] = $dir;
918
+				if (!in_array($dir, $open_basedirs))
919
+				{
920
+					$need_adding[] = $dir;
921
+				}
852 922
 			}
853 923
 			if ($need_adding)
854 924
 			{
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_admin.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,8 +75,7 @@
 block discarded – undo
75 75
 	/**
76 76
 	 * Mount GUI
77 77
 	 *
78
-	 * @param array $content=null
79
-	 * @param string $msg=''
78
+	 * @param array $content
80 79
 	 */
81 80
 	public function index(array $content=null, $msg='', $msg_type=null)
82 81
 	{
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -131,7 +131,10 @@  discard block
 block discarded – undo
131 131
 					($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount']))
132 132
 				{
133 133
 					$url = str_replace('$path',$path,$content['mounts']['url']);
134
-					if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path;
134
+					if (empty($url) && $this->versioning)
135
+					{
136
+						$url = Versioning\StreamWrapper::PREFIX.$path;
137
+					}
135 138
 
136 139
 					if ($content['mounts']['enable'] && !$this->versioning)
137 140
 					{
@@ -227,16 +230,25 @@  discard block
 block discarded – undo
227 230
 			$content['versionedpath'] = '/';
228 231
 			$content['mtime'] = 100;
229 232
 		}
230
-		if (true) $content = array(
233
+		if (true)
234
+		{
235
+			$content = array(
231 236
 			'versionedpath' => $content['versionedpath'],
232 237
 			'mtime' => $content['mtime'],
233 238
 		);
239
+		}
234 240
 		if ($this->versioning)
235 241
 		{
236 242
 			// statistical information
237 243
 			$content += Versioning\StreamWrapper::summary();
238
-			if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
239
-			if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
244
+			if ($content['total_files'])
245
+			{
246
+				$content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
247
+			}
248
+			if ($content['total_size'])
249
+			{
250
+				$content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
251
+			}
240 252
 		}
241 253
 		if (!($content['is_root']=Vfs::$is_root))
242 254
 		{
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	 * @param array $content=null
79 79
 	 * @param string $msg=''
80 80
 	 */
81
-	public function index(array $content=null, $msg='', $msg_type=null)
81
+	public function index(array $content = null, $msg = '', $msg_type = null)
82 82
 	{
83 83
 		if (is_array($content))
84 84
 		{
85 85
 			//_debug_array($content);
86 86
 			if ($content['sudo'])
87 87
 			{
88
-				$msg = $this->sudo($content['user'],$content['password'],self::$is_setup) ?
88
+				$msg = $this->sudo($content['user'], $content['password'], self::$is_setup) ?
89 89
 					lang('Root access granted.') : lang('Wrong username or password!');
90 90
 				$msg_type = Vfs::$is_root ? 'success' : 'error';
91 91
 			}
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 				Vfs::chgrp($path, 'Admins');
100 100
 				Vfs::chmod($path, 075);
101 101
 				$msg = Vfs::mount($url, $path) ?
102
-					lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path);
102
+					lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path);
103 103
 				Vfs::$is_root = $backup;
104 104
 			}
105 105
 			elseif (Vfs::$is_root)
106 106
 			{
107 107
 				if ($content['logout'])
108 108
 				{
109
-					$msg = $this->sudo('','',self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.');
109
+					$msg = $this->sudo('', '', self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.');
110 110
 					$msg_type = !Vfs::$is_root ? 'success' : 'error';
111 111
 				}
112 112
 				if ($content['mounts']['disable'] || self::$is_setup && $content['mounts']['umount'])
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 					if (!in_array($path, self::$protected_path) && $path != '/')
123 123
 					{
124 124
 						$msg = Vfs::umount($path) ?
125
-							lang('%1 successful unmounted.',$path) : lang('Error unmounting %1!',$path);
125
+							lang('%1 successful unmounted.', $path) : lang('Error unmounting %1!', $path);
126 126
 					}
127 127
 					else	// re-mount / with sqlFS, to disable versioning
128 128
 					{
129
-						$msg = Vfs::mount($url=Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path,$path) ?
130
-							lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path);
129
+						$msg = Vfs::mount($url = Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path, $path) ?
130
+							lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path);
131 131
 					}
132 132
 				}
133 133
 				if (($path = $content['mounts']['path']) &&
134 134
 					($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount']))
135 135
 				{
136
-					$url = str_replace('$path',$path,$content['mounts']['url']);
136
+					$url = str_replace('$path', $path, $content['mounts']['url']);
137 137
 					if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path;
138 138
 
139 139
 					if ($content['mounts']['enable'] && !$this->versioning)
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 					}
144 144
 					elseif (!Vfs::file_exists($path) || !Vfs::is_dir($path))
145 145
 					{
146
-						$msg = lang('Path %1 not found or not a directory!',$path);
146
+						$msg = lang('Path %1 not found or not a directory!', $path);
147 147
 						$msg_type = 'error';
148 148
 					}
149 149
 					// dont allow to change mount of /apps or /templates (eg. switching on versioning)
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 					}
155 155
 					else
156 156
 					{
157
-						$msg = Vfs::mount($url,$path) ?
158
-							lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path);
157
+						$msg = Vfs::mount($url, $path) ?
158
+							lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path);
159 159
 					}
160 160
 				}
161 161
 				if ($content['allow_delete_versions'] != $GLOBALS['egw_info']['server']['allow_delete_versions'])
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 								'hidden' => true,
201 201
 								'depth' => true,
202 202
 								'path_preg' => '#/\.(attic|versions)/#',
203
-							)+(!(int)$content['mtime'] ? array() : array(
204
-								'mtime' => ($content['mtime']<0?'-':'+').(int)$content['mtime'],
203
+							) + (!(int)$content['mtime'] ? array() : array(
204
+								'mtime' => ($content['mtime'] < 0 ? '-' : '+').(int)$content['mtime'],
205 205
 							)), function($path) use (&$deleted, &$errors)
206 206
 							{
207 207
 								if (($is_dir = Vfs::is_dir($path)) && Vfs::rmdir($path) ||
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 								}
216 216
 							});
217 217
 						}
218
-						$time = number_format(microtime(true)-$starttime, 1);
218
+						$time = number_format(microtime(true) - $starttime, 1);
219 219
 						$msg = ($errors ? lang('%1 errors deleting!', $errors)."\n\n" : '').
220 220
 							lang('%1 files or directories deleted in %2 seconds.', $deleted, $time);
221 221
 						$msg_type = $errors ? 'error' : 'info';
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 		{
239 239
 			// statistical information
240 240
 			$content += Versioning\StreamWrapper::summary();
241
-			if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
242
-			if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
241
+			if ($content['total_files']) $content['percent_files'] = number_format(100.0 * $content['version_files'] / $content['total_files'], 1).'%';
242
+			if ($content['total_size']) $content['percent_size'] = number_format(100.0 * $content['version_size'] / $content['total_size'], 1).'%';
243 243
 		}
244
-		if (!($content['is_root']=Vfs::$is_root))
244
+		if (!($content['is_root'] = Vfs::$is_root))
245 245
 		{
246 246
 			if (empty($msg))
247 247
 			{
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$n = 2;
259 259
 		$content['mounts'] = array();
260
-		foreach(Vfs::mount() as $path => $url)
260
+		foreach (Vfs::mount() as $path => $url)
261 261
 		{
262 262
 			$content['mounts'][$n++] = array(
263 263
 				'path' => $path,
264 264
 				'url'  => $url,
265 265
 			);
266 266
 			$readonlys["disable[$path]"] = !$this->versioning || !Vfs::$is_root ||
267
-				Vfs::parse_url($url,PHP_URL_SCHEME) != $this->versioning;
267
+				Vfs::parse_url($url, PHP_URL_SCHEME) != $this->versioning;
268 268
 		}
269
-		$readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true;	// do not allow to unmount / or /apps
269
+		$readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps
270 270
 		$readonlys['url'] = !self::$is_setup;
271 271
 
272 272
 		$sel_options['allow_delete_versions'] = array(
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 		);
277 277
 		// show [Mount /etemplates] button for admin, if not already mounted and available
278 278
 		$readonlys['etemplates'] = !class_exists('\EGroupware\Stylite\Vfs\Merge\StreamWrapper') ||
279
-			($fs_tab=Vfs::mount($url)) && isset($fs_tab['/etemplates']) ||
279
+			($fs_tab = Vfs::mount($url)) && isset($fs_tab['/etemplates']) ||
280 280
 			!isset($GLOBALS['egw_info']['user']['apps']['admin']);
281 281
 		//_debug_array($content);
282 282
 
283 283
 		$tpl = new Etemplate('filemanager.admin');
284 284
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('VFS mounts and versioning');
285
-		$tpl->exec('filemanager.filemanager_admin.index',$content,$sel_options,$readonlys);
285
+		$tpl->exec('filemanager.filemanager_admin.index', $content, $sel_options, $readonlys);
286 286
 	}
287 287
 
288 288
 	/**
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 		$content = '<p>'.implode("</p>\n<p>", (array)$msgs)."</p>\n";
304 304
 
305
-		$content .= Api\Html::form('<p>'.($check_only&&is_array($msgs) ?
305
+		$content .= Api\Html::form('<p>'.($check_only && is_array($msgs) ?
306 306
 			Api\Html::submit_button('fix', lang('Fix reported problems')) : '').
307 307
 			Api\Html::submit_button('cancel', lang('Cancel')).'</p>',
308
-			'','/index.php',array('menuaction'=>'filemanager.filemanager_admin.fsck'));
308
+			'', '/index.php', array('menuaction'=>'filemanager.filemanager_admin.fsck'));
309 309
 
310 310
 		$GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true);
311 311
 	}
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_favorite_portlet.inc.php 4 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -92,8 +92,6 @@
 block discarded – undo
92 92
 	 * Here we need to handle any incoming data.  Setup is done in the constructor,
93 93
 	 * output is handled by parent.
94 94
 	 *
95
-	 * @param type $id
96
-	 * @param Etemplate $etemplate
97 95
 	 */
98 96
 	public static function process($content = array())
99 97
 	{
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,10 @@
 block discarded – undo
104 104
 		if ($content['nm']['action'])
105 105
 		{
106 106
 			$msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
107
-			if($msg) Api\Json\Response::get()->apply('egw.message',array($msg));
107
+			if($msg)
108
+			{
109
+				Api\Json\Response::get()->apply('egw.message',array($msg));
110
+			}
108 111
 			foreach($content['nm']['selected'] as &$id)
109 112
 			{
110 113
 				$id = 'filemanager::'.$id;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	 * Construct the portlet
24 24
 	 *
25 25
 	 */
26
-	public function __construct(Array &$context = array(), &$need_reload = false)
26
+	public function __construct(array &$context = array(), &$need_reload = false)
27 27
 	{
28 28
 		$context['appname'] = 'filemanager';
29 29
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 		$context['appname'] = 'filemanager';
29 29
 
30 30
 		// Let parent handle the basic stuff
31
-		parent::__construct($context,$need_reload);
31
+		parent::__construct($context, $need_reload);
32 32
 
33 33
 		$this->nm_settings += array(
34 34
 			'get_rows'       => 'filemanager.filemanager_favorite_portlet.get_rows',
35 35
 			'csv_export'     => true,
36 36
 			// Use a different template so it can be accessed from client side
37
-			'template'       => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows' ),
37
+			'template'       => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows'),
38 38
 			// Filemanager needs this header, it's an important component for actions, but we reduce it to the minimum
39 39
 			'header_left'    => 'filemanager.home.header_left',
40 40
 			// Use a reduced column set for home, user can change if needed
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			'parent_id'      => 'dir',
47 47
 			'is_parent'      => 'mime',
48 48
 			'is_parent_value'=> Vfs::DIR_MIME_TYPE,
49
-			'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
49
+			'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink')
50 50
 		);
51 51
 	}
52 52
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		$ui = new filemanager_ui();
81 81
 		$total = $ui->get_rows($query, $rows, $readonlys);
82 82
 		// Change template to match selected view
83
-		if($query['view'])
83
+		if ($query['view'])
84 84
 		{
85 85
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.home.rows' : 'filemanager.tile');
86 86
 		}
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 		// the etemplate exec to fire again.
104 104
 		if ($content['nm']['action'])
105 105
 		{
106
-			$msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
107
-			if($msg) Api\Json\Response::get()->apply('egw.message',array($msg));
108
-			foreach($content['nm']['selected'] as &$id)
106
+			$msg = filemanager_ui::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
107
+			if ($msg) Api\Json\Response::get()->apply('egw.message', array($msg));
108
+			foreach ($content['nm']['selected'] as &$id)
109 109
 			{
110 110
 				$id = 'filemanager::'.$id;
111 111
 			}
112 112
 			// Directly request an update - this will get filemanager tab too
113
-			Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
113
+			Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected']));
114 114
 		}
115 115
 	}
116 116
  }
117 117
\ No newline at end of file
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
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		);
104 104
 		if ($location == 'admin')
105 105
 		{
106
-        	display_section(self::$appname,$file);
106
+			display_section(self::$appname,$file);
107 107
 		}
108 108
 		else
109 109
 		{
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			'yes' => lang('Yes')
124 124
 		);
125 125
 
126
-        $settings = array(
126
+		$settings = array(
127 127
 			'sections.1' => array(
128 128
 				'type'  => 'section',
129 129
 				'title' => lang('General settings'),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 	{
96 96
 		if (is_array($location)) $location = $location['location'];
97 97
 
98
-		$file = Array(
98
+		$file = array(
99 99
 			//'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'),
100 100
 			'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'),
101 101
 			'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'),
Please login to merge, or discard this patch.
Braces   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,10 @@  discard block
 block discarded – undo
83 83
 			$file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
84 84
 			display_sidebox(self::$appname,$title,$file);
85 85
 		}
86
-		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
86
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
87
+		{
88
+			self::admin(self::$appname);
89
+		}
87 90
 	}
88 91
 
89 92
 	/**
@@ -93,7 +96,10 @@  discard block
 block discarded – undo
93 96
 	 */
94 97
 	static function admin($location = 'admin')
95 98
 	{
96
-		if (is_array($location)) $location = $location['location'];
99
+		if (is_array($location))
100
+		{
101
+			$location = $location['location'];
102
+		}
97 103
 
98 104
 		$file = Array(
99 105
 			//'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'),
@@ -315,7 +321,11 @@  discard block
 block discarded – undo
315 321
 			{
316 322
 				$link = $l[$app];
317 323
 			}
318
-			if ($app == 'collabora') break; // collabora is default
324
+			if ($app == 'collabora')
325
+			{
326
+				break;
327
+			}
328
+			// collabora is default
319 329
 		}
320 330
 		return $link;
321 331
 	}
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 		$basepath = '/home';
37 37
 		$homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
38 38
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
39
-		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
39
+		$file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
40 40
 		if ($location == 'sidebox_menu')
41 41
 		{
42
-			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu');
42
+			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu');
43 43
 			$file = array();
44
-			if($GLOBALS['egw_info']['apps']['stylite'])
44
+			if ($GLOBALS['egw_info']['apps']['stylite'])
45 45
 			{
46 46
 				// add "file a file" (upload) dialog
47 47
 				$file[] = array(
@@ -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' => Api\Html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false,
59
+					'text' => Api\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 78
 			if (!empty($file_prefs['startfolder']))
79 79
 			{
80
-				$file['Startfolder']= Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
80
+				$file['Startfolder'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true'));
81 81
 			}
82
-			$file['Placeholders'] = Egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements');
83
-			$file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
84
-			display_sidebox(self::$appname,$title,$file);
82
+			$file['Placeholders'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements');
83
+			$file['Shared files'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true');
84
+			display_sidebox(self::$appname, $title, $file);
85 85
 		}
86 86
 		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
87 87
 	}
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 
98 98
 		$file = Array(
99 99
 			//'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'),
100
-			'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'),
101
-			'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'),
100
+			'Custom fields' => Egw::link('/index.php', 'menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'),
101
+			'Check virtual filesystem' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'),
102 102
 			'VFS mounts and versioning' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'),
103 103
 		);
104 104
 		if ($location == 'admin')
105 105
 		{
106
-        	display_section(self::$appname,$file);
106
+        	display_section(self::$appname, $file);
107 107
 		}
108 108
 		else
109 109
 		{
110
-			display_sidebox(self::$appname,lang('Admin'),$file);
110
+			display_sidebox(self::$appname, lang('Admin'), $file);
111 111
 		}
112 112
 	}
113 113
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				'type'		=> 'select',
158 158
 				'name'		=> 'showhome',
159 159
 				'values'	=> $yes_no,
160
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Your home directory')),
160
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Your home directory')),
161 161
 				'xmlrpc'	=> True,
162 162
 				'admin'		=> False,
163 163
 				'forced'   => 'yes',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 				'type'		=> 'select',
167 167
 				'name'		=> 'showusers',
168 168
 				'values'	=> $yes_no,
169
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Users and groups')),
169
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Users and groups')),
170 170
 				'xmlrpc'	=> True,
171 171
 				'admin'		=> False,
172 172
 				'forced'   => 'yes',
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 			'size'   => 60,
179 179
 			'label'  => 'Default document to insert entries',
180 180
 			'name'   => 'default_document',
181
-			'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')).' '.
181
+			'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')).' '.
182 182
 				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
183
-				lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
183
+				lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()),
184 184
 			'run_lang' => false,
185 185
 			'xmlrpc' => True,
186 186
 			'admin'  => False,
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 			'label'  => 'Directory with documents to insert entries',
192 192
 			'name'   => 'document_dir',
193 193
 			'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')).' '.
194
-				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '.
195
-				lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
194
+				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
195
+				lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()),
196 196
 			'run_lang' => false,
197 197
 			'xmlrpc' => True,
198 198
 			'admin'  => False,
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			}
247 247
 		}
248 248
 		asort($mimes);
249
-		$settings += array (
249
+		$settings += array(
250 250
 			'sections.2' => array(
251 251
 				'type'  => 'section',
252 252
 				'title' => lang('Collab Editor settings'),
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				'type' => 'color',
259 259
 				'label' => lang('User color indicator'),
260 260
 				'name' => 'collab_user_color',
261
-				'help' => lang('Use eg. %1 or %2','#FF0000','orange'),
261
+				'help' => lang('Use eg. %1 or %2', '#FF0000', 'orange'),
262 262
 				'no_lang'=> true,
263 263
 				'xmlrpc' => True,
264 264
 				'admin'  => False,
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 				'label'  => lang('Merge print open handler'),
282 282
 				'help'   => lang('Defines how to open a merge print document'),
283 283
 				'name'   => 'merge_open_handler',
284
-				'values' => array ('download' => lang('download'), 'collabora' => 'Collabora'),
284
+				'values' => array('download' => lang('download'), 'collabora' => 'Collabora'),
285 285
 				'default' => 'collabora',
286 286
 			)
287 287
 		);
@@ -332,13 +332,13 @@  discard block
 block discarded – undo
332 332
 		$implemented = Api\Hooks::implemented('filemanager-editor-link');
333 333
 		// default is CollabEditor
334 334
 		// TODO: CollabEditor needs to be migrated into an individual app, so its link
335
-		$link = array (
335
+		$link = array(
336 336
 			'edit' => array(
337 337
 				'menuaction' => 'filemanager.filemanager_ui.editor',
338 338
 			),
339 339
 			'edit_popup' => '980x750',
340
-			'mime' => array (
341
-				'application/vnd.oasis.opendocument.text' => array (
340
+			'mime' => array(
341
+				'application/vnd.oasis.opendocument.text' => array(
342 342
 					'mime_popup' => '', // try to avoid mime_open exception
343 343
 					'ext' => 'odt'
344 344
 				),
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 		foreach ($implemented as $app)
348 348
 		{
349 349
 
350
-			if ( \EGroupware\Api\Vfs\Links\StreamWrapper::check_app_rights($app) &&
351
-					($l = Api\Hooks::process('filemanager-editor-link',$app, true)) && $l[$app])
350
+			if (\EGroupware\Api\Vfs\Links\StreamWrapper::check_app_rights($app) &&
351
+					($l = Api\Hooks::process('filemanager-editor-link', $app, true)) && $l[$app])
352 352
 			{
353 353
 				$link = $l[$app];
354 354
 			}
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.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$readonlys = null;
90 90
 		$total = Sharing::so()->get_rows($query, $rows, $readonlys);
91 91
 
92
-		foreach($rows as &$row)
92
+		foreach ($rows as &$row)
93 93
 		{
94 94
 			if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir)
95 95
 			{
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
 	 * @param array $content=null
131 131
 	 * @param string $msg=''
132 132
 	 */
133
-	public function index(array $content=null)
133
+	public function index(array $content = null)
134 134
 	{
135 135
 		if (!is_array($content))
136 136
 		{
137 137
 			$content = array(
138 138
 				'nm' => array(
139
-					'get_rows'       =>	'filemanager.filemanager_shares.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
140
-					'no_filter'      => True,	// current dir only
141
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
142
-					'no_cat'         => True,	// I  disable the cat-selectbox
143
-					'lettersearch'   => false,	// I  show a lettersearch
144
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
145
-					'start'          =>	0,		// IO position in list
146
-					'order'          =>	'share_created',	// IO name of the column to sort after (optional for the sortheaders)
147
-					'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
139
+					'get_rows'       =>	'filemanager.filemanager_shares.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
140
+					'no_filter'      => True, // current dir only
141
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
142
+					'no_cat'         => True, // I  disable the cat-selectbox
143
+					'lettersearch'   => false, // I  show a lettersearch
144
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
145
+					'start'          =>	0, // IO position in list
146
+					'order'          =>	'share_created', // IO name of the column to sort after (optional for the sortheaders)
147
+					'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
148 148
 					//'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
149 149
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
150 150
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		}
157 157
 		elseif ($content['nm']['action'])
158 158
 		{
159
-			switch($content['nm']['action'])
159
+			switch ($content['nm']['action'])
160 160
 			{
161 161
 				case 'delete':
162 162
 					$where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']);
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.
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   +210 added lines, -212 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 		if (!static::$views_init)
82 82
 		{
83 83
 			// translate our labels
84
-			foreach(static::$views as &$label)
84
+			foreach (static::$views as &$label)
85 85
 			{
86 86
 				$label = lang($label);
87 87
 			}
88 88
 			// search for plugins with additional filemanager views
89
-			foreach(Api\Hooks::process('filemanager_views') as $views)
89
+			foreach (Api\Hooks::process('filemanager_views') as $views)
90 90
 			{
91 91
 				if (is_array($views)) static::$views += $views;
92 92
 			}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public static function get_view()
104 104
 	{
105
-		$view =& Api\Cache::getSession('filemanager', 'view');
105
+		$view = & Api\Cache::getSession('filemanager', 'view');
106 106
 		if (isset($_GET['view']))
107 107
 		{
108 108
 			$view = $_GET['view'];
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 	 * @param type $actions
121 121
 	 * @return type
122 122
 	 */
123
-	public static function convertActionsToselOptions ($actions)
123
+	public static function convertActionsToselOptions($actions)
124 124
 	{
125
-		$sel_options = array ();
125
+		$sel_options = array();
126 126
 		foreach ($actions as $action => $value)
127 127
 		{
128
-			$sel_options[$action] = array (
128
+			$sel_options[$action] = array(
129 129
 				'label' => $value['caption'],
130 130
 				'icon'	=> $value['icon']
131 131
 			);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			'open' => array(
145 145
 				'caption' => lang('Open'),
146 146
 				'icon' => '',
147
-				'group' => $group=1,
147
+				'group' => $group = 1,
148 148
 				'allowOnMultiple' => false,
149 149
 				'onExecute' => 'javaScript:app.filemanager.open',
150 150
 				'default' => true
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 				'caption' => 'New',
154 154
 				'group' => $group,
155 155
 				'disableClass' => 'noEdit',
156
-				'children' => array (
157
-					'document' => array (
156
+				'children' => array(
157
+					'document' => array(
158 158
 						'caption' => 'Document',
159 159
 						'icon' => 'new',
160 160
 						'onExecute' => 'javaScript:app.filemanager.create_new',
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				'caption' => lang('Edit settings'),
174 174
 				'group' => $group,
175 175
 				'allowOnMultiple' => false,
176
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs',
176
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.filemanager.viewEntry' : 'javaScript:app.filemanager.editprefs',
177 177
 				'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet'))
178 178
 			),
179 179
 			'share' => array(
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			),
253 253
 			// DRAG and DROP events
254 254
 			'file_drag' => array(
255
-				'dragType' => array('file','link'),
255
+				'dragType' => array('file', 'link'),
256 256
 				'type' => 'drag',
257 257
 				'onExecute' => 'javaScript:app.filemanager.drag'
258 258
 			),
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		);
288 288
 
289 289
 		if (isset($GLOBALS['egw_info']['user']['apps']['mail'])) {
290
-			foreach(Vfs\Sharing::$modes as $mode => $data)
290
+			foreach (Vfs\Sharing::$modes as $mode => $data)
291 291
 			{
292 292
 				$actions['share']['children']['mail_'.$mode] = array(
293 293
 					'caption' => $data['label'],
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		// This would be done automatically, but we're overriding
306
-		foreach($actions as $action_id => $action)
306
+		foreach ($actions as $action_id => $action)
307 307
 		{
308
-			if($action['type'] == 'drop' && $action['caption'])
308
+			if ($action['type'] == 'drop' && $action['caption'])
309 309
 			{
310 310
 				$action['type'] = 'popup';
311
-				if($action['acceptedTypes'] == 'file')
311
+				if ($action['acceptedTypes'] == 'file')
312 312
 				{
313 313
 					$action['enabled'] = 'javaScript:app.filemanager.paste_enabled';
314 314
 				}
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @return string merge application or NULL if no property found
330 330
 	 */
331
-	private static function get_mergeapp($path, $scope='self')
331
+	private static function get_mergeapp($path, $scope = 'self')
332 332
 	{
333 333
 		$app = null;
334
-		switch($scope)
334
+		switch ($scope)
335 335
 		{
336 336
 			case 'self':
337 337
 				$props = Vfs::propfind($path, static::$merge_prop_namespace);
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 			case 'parents':
341 341
 				// search for props in parent directories
342 342
 				$currentpath = $path;
343
-				while($dir = Vfs::dirname($currentpath))
343
+				while ($dir = Vfs::dirname($currentpath))
344 344
 				{
345 345
 					$props = Vfs::propfind($dir, static::$merge_prop_namespace);
346
-					if(!empty($props))
346
+					if (!empty($props))
347 347
 					{
348 348
 						// found prop in parent directory
349 349
 						return $app = $props[0]['val'];
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * @param array $content
363 363
 	 * @param string $msg
364 364
 	 */
365
-	function index(array $content=null,$msg=null)
365
+	function index(array $content = null, $msg = null)
366 366
 	{
367 367
 		if (!is_array($content))
368 368
 		{
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
 			if (!is_array($content['nm']))
373 373
 			{
374 374
 				$content['nm'] = array(
375
-					'get_rows'       =>	'filemanager.filemanager_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
376
-					'filter'         => '',	// current dir only
377
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
378
-					'no_cat'         => True,	// I  disable the cat-selectbox
379
-					'lettersearch'   => True,	// I  show a lettersearch
380
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
381
-					'start'          =>	0,		// IO position in list
382
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
383
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
384
-					'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
375
+					'get_rows'       =>	'filemanager.filemanager_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
376
+					'filter'         => '', // current dir only
377
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
378
+					'no_cat'         => True, // I  disable the cat-selectbox
379
+					'lettersearch'   => True, // I  show a lettersearch
380
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
381
+					'start'          =>	0, // IO position in list
382
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
383
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
384
+					'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
385 385
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
386 386
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
387 387
 					'row_id'         => 'path',
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 			$content['nm']['actions'] = static::get_actions();
396 396
 			$content['nm']['home_dir'] = static::get_home_dir();
397 397
 			$content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view'];
398
-			$content['nm']['placeholder_actions'] = array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink');
398
+			$content['nm']['placeholder_actions'] = array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink');
399 399
 
400 400
 			if (isset($_GET['msg'])) $msg = $_GET['msg'];
401 401
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 			}
412 412
 			if (isset($_GET['path']) && ($path = $_GET['path']))
413 413
 			{
414
-				switch($path)
414
+				switch ($path)
415 415
 				{
416 416
 					case '..':
417 417
 						$path = Vfs::dirname($content['nm']['path']);
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 						$path = static::get_home_dir();
421 421
 						break;
422 422
 				}
423
-				if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE))
423
+				if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE))
424 424
 				{
425 425
 					$content['nm']['path'] = $path;
426 426
 				}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 		$view = static::get_view();
438 438
 
439
-		call_user_func($view,$content,$msg);
439
+		call_user_func($view, $content, $msg);
440 440
 	}
441 441
 
442 442
 	/**
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	 * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise
450 450
 	 * @return boolean true is root user given, false otherwise (including logout / empty $user)
451 451
 	 */
452
-	protected function sudo($user='',$password=null,&$is_setup=null)
452
+	protected function sudo($user = '', $password = null, &$is_setup = null)
453 453
 	{
454 454
 		if (!$user)
455 455
 		{
@@ -458,15 +458,15 @@  discard block
 block discarded – undo
458 458
 		else
459 459
 		{
460 460
 			// config user & password
461
-			$is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash'];
461
+			$is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash'];
462 462
 			// or vfs root user from setup >> configuration
463
-			$is_root = $is_setup ||	$GLOBALS['egw_info']['server']['vfs_root_user'] &&
464
-				in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) &&
463
+			$is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] &&
464
+				in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) &&
465 465
 				$GLOBALS['egw']->auth->authenticate($user, $password, 'text');
466 466
 		}
467 467
 		//error_log(__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".Api\Session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root));
468
-		Api\Cache::setSession('filemanager', 'is_setup',$is_setup);
469
-		Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root);
468
+		Api\Cache::setSession('filemanager', 'is_setup', $is_setup);
469
+		Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root);
470 470
 		return Vfs::$is_root;
471 471
 	}
472 472
 
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
 	 * @param array $content
477 477
 	 * @param string $msg
478 478
 	 */
479
-	function listview(array $content=null,$msg=null)
479
+	function listview(array $content = null, $msg = null)
480 480
 	{
481 481
 		$tpl = new Etemplate('filemanager.index');
482 482
 
483
-		if($msg) Framework::message($msg);
483
+		if ($msg) Framework::message($msg);
484 484
 
485 485
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
486 486
 		{
487 487
 			if ($content['nm']['action'])
488 488
 			{
489
-				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
490
-				if($msg) Framework::message($msg);
489
+				$msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
490
+				if ($msg) Framework::message($msg);
491 491
 
492 492
 				// clean up after action
493 493
 				unset($content['nm']['selected']);
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
499 499
 				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
500 500
 			}
501
-			elseif($content['nm']['rows']['delete'])
501
+			elseif ($content['nm']['rows']['delete'])
502 502
 			{
503
-				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
504
-				if($msg) Framework::message($msg);
503
+				$msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']);
504
+				if ($msg) Framework::message($msg);
505 505
 
506 506
 				// clean up after action
507 507
 				unset($content['nm']['rows']['delete']);
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
514 514
 			}
515 515
 			unset($content['nm']['rows']);
516
-			Api\Cache::setSession('filemanager', 'index',$content['nm']);
516
+			Api\Cache::setSession('filemanager', 'index', $content['nm']);
517 517
 		}
518 518
 
519 519
 		// be tolerant with (in previous versions) not correct urlencoded pathes
520
-		if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path'])))
520
+		if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path'])))
521 521
 		{
522 522
 			$content['nm']['path'] = urldecode($content['nm']['path']);
523 523
 		}
@@ -528,22 +528,22 @@  discard block
 block discarded – undo
528 528
 				list($button) = each($content['button']);
529 529
 				unset($content['button']);
530 530
 			}
531
-			switch($button)
531
+			switch ($button)
532 532
 			{
533 533
 				case 'upload':
534 534
 					if (!$content['upload'])
535 535
 					{
536
-						Framework::message(lang('You need to select some files first!'),'error');
536
+						Framework::message(lang('You need to select some files first!'), 'error');
537 537
 						break;
538 538
 					}
539 539
 					$upload_success = $upload_failure = array();
540
-					foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
540
+					foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
541 541
 					{
542 542
 						// encode chars which special meaning in url/vfs (some like / get removed!)
543
-						$to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name']));
543
+						$to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name']));
544 544
 						if ($upload &&
545 545
 							(Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) &&
546
-							copy($upload['tmp_name'],Vfs::PREFIX.$to))
546
+							copy($upload['tmp_name'], Vfs::PREFIX.$to))
547 547
 						{
548 548
 							$upload_success[] = $upload['name'];
549 549
 						}
@@ -555,12 +555,11 @@  discard block
 block discarded – undo
555 555
 					$content['nm']['msg'] = '';
556 556
 					if ($upload_success)
557 557
 					{
558
-						Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
559
-							lang('%1 successful uploaded.',implode(', ',$upload_success)));
558
+						Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success)));
560 559
 					}
561 560
 					if ($upload_failure)
562 561
 					{
563
-						Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error');
562
+						Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error');
564 563
 					}
565 564
 					break;
566 565
 			}
@@ -584,16 +583,16 @@  discard block
 block discarded – undo
584 583
 			$tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv');
585 584
 		}
586 585
 		// Set view button to match current settings
587
-		if($content['nm']['view'] == 'tile')
586
+		if ($content['nm']['view'] == 'tile')
588 587
 		{
589
-			$tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view'));
590
-			$tpl->setElementAttribute('nm[button][change_view]','image','list_row');
588
+			$tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view'));
589
+			$tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row');
591 590
 		}
592 591
 		// if initial load is done via GET request (idots template or share.php)
593 592
 		// get_rows cant call app.filemanager.set_readonly, so we need to do that here
594 593
 		$content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']);
595 594
 
596
-		$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
595
+		$tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm']));
597 596
 	}
598 597
 
599 598
 	/**
@@ -629,7 +628,7 @@  discard block
 block discarded – undo
629 628
 	 * @param int &$files=null on return number of files deleted
630 629
 	 * @return string success or failure message displayed to the user
631 630
 	 */
632
-	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
631
+	static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null)
633 632
 	{
634 633
 		if (!count($selected))
635 634
 		{
@@ -637,20 +636,20 @@  discard block
 block discarded – undo
637 636
 		}
638 637
 		$errs = $dirs = $files = 0;
639 638
 
640
-		switch($action)
639
+		switch ($action)
641 640
 		{
642 641
 
643 642
 			case 'delete':
644
-				return static::do_delete($selected,$errs,$files,$dirs);
643
+				return static::do_delete($selected, $errs, $files, $dirs);
645 644
 
646 645
 			case 'mail':
647 646
 			case 'copy':
648
-				foreach($selected as $path)
647
+				foreach ($selected as $path)
649 648
 				{
650 649
 					if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
651 650
 					{
652 651
 						// Support for dropping mail in filemanager - Pass mail back to mail app
653
-						if(ExecMethod2('mail.mail_ui.vfsSaveMessages', $path, $dir))
652
+						if (ExecMethod2('mail.mail_ui.vfsSaveMessages', $path, $dir))
654 653
 						{
655 654
 							++$files;
656 655
 						}
@@ -661,8 +660,8 @@  discard block
 block discarded – undo
661 660
 					}
662 661
 					elseif (!Vfs::is_dir($path))
663 662
 					{
664
-						$to = Vfs::concat($dir,Vfs::basename($path));
665
-						if ($path != $to && Vfs::copy($path,$to))
663
+						$to = Vfs::concat($dir, Vfs::basename($path));
664
+						if ($path != $to && Vfs::copy($path, $to))
666 665
 						{
667 666
 							++$files;
668 667
 						}
@@ -674,19 +673,19 @@  discard block
 block discarded – undo
674 673
 					else
675 674
 					{
676 675
 						$len = strlen(dirname($path));
677
-						foreach(Vfs::find($path) as $p)
676
+						foreach (Vfs::find($path) as $p)
678 677
 						{
679
-							$to = $dir.substr($p,$len);
678
+							$to = $dir.substr($p, $len);
680 679
 							if ($to == $p)	// cant copy into itself!
681 680
 							{
682 681
 								++$errs;
683 682
 								continue;
684 683
 							}
685
-							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
684
+							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE))
686 685
 							{
687 686
 								++$dirs;
688 687
 							}
689
-							elseif(!$is_dir && Vfs::copy($p,$to))
688
+							elseif (!$is_dir && Vfs::copy($p, $to))
690 689
 							{
691 690
 								++$files;
692 691
 							}
@@ -699,15 +698,15 @@  discard block
 block discarded – undo
699 698
 				}
700 699
 				if ($errs)
701 700
 				{
702
-					return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files);
701
+					return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files);
703 702
 				}
704
-				return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
703
+				return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files);
705 704
 
706 705
 			case 'move':
707
-				foreach($selected as $path)
706
+				foreach ($selected as $path)
708 707
 				{
709
-					$to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir;
710
-					if ($path != $to && Vfs::rename($path,$to))
708
+					$to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir;
709
+					if ($path != $to && Vfs::rename($path, $to))
711 710
 					{
712 711
 						++$files;
713 712
 					}
@@ -718,17 +717,17 @@  discard block
 block discarded – undo
718 717
 				}
719 718
 				if ($errs)
720 719
 				{
721
-					return lang('%1 errors moving (%2 files moved)!',$errs,$files);
720
+					return lang('%1 errors moving (%2 files moved)!', $errs, $files);
722 721
 				}
723
-				return lang('%1 files moved.',$files);
722
+				return lang('%1 files moved.', $files);
724 723
 
725 724
 			case 'symlink':	// symlink given files to $dir
726
-				foreach((array)$selected as $target)
725
+				foreach ((array)$selected as $target)
727 726
 				{
728 727
 					$link = Vfs::concat($dir, Vfs::basename($target));
729
-					if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true)))
728
+					if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true)))
730 729
 					{
731
-						if(!$ok)
730
+						if (!$ok)
732 731
 						{
733 732
 							$errs++;
734 733
 							continue;
@@ -750,15 +749,14 @@  discard block
 block discarded – undo
750 749
 				}
751 750
 				if (count((array)$selected) == 1)
752 751
 				{
753
-					return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) :
754
-						lang('Error creating symlink to target %1!', Vfs::decodePath($target));
752
+					return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target));
755 753
 				}
756 754
 				$ret = lang('%1 elements linked.', $files);
757 755
 				if ($errs)
758 756
 				{
759
-					$ret = lang('%1 errors linking (%2)!',$errs, $ret);
757
+					$ret = lang('%1 errors linking (%2)!', $errs, $ret);
760 758
 				}
761
-				return $ret;//." Vfs::symlink('$target', '$link')";
759
+				return $ret; //." Vfs::symlink('$target', '$link')";
762 760
 
763 761
 			case 'createdir':
764 762
 				$dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
@@ -774,13 +772,13 @@  discard block
 block discarded – undo
774 772
 
775 773
 			default:
776 774
 				list($action, $settings) = explode('_', $action, 2);
777
-				switch($action)
775
+				switch ($action)
778 776
 				{
779 777
 					case 'document':
780 778
 						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
781 779
 						$document_merge = new filemanager_merge(Vfs::decodePath($dir));
782 780
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
783
-						if($msg) return $msg;
781
+						if ($msg) return $msg;
784 782
 						$errs = count($selected);
785 783
 						return false;
786 784
 				}
@@ -797,12 +795,12 @@  discard block
 block discarded – undo
797 795
 	 * @param int &$files=null on return number of files deleted
798 796
 	 * @return string
799 797
 	 */
800
-	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
798
+	public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null)
801 799
 	{
802 800
 		$dirs = $files = $errs = 0;
803 801
 		// we first delete all selected links (and files)
804 802
 		// feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link!
805
-		foreach($selected as $key => $path)
803
+		foreach ($selected as $key => $path)
806 804
 		{
807 805
 			if (!Vfs::is_dir($path) || Vfs::is_link($path))
808 806
 			{
@@ -820,21 +818,21 @@  discard block
 block discarded – undo
820 818
 		if ($selected)	// somethings left to delete
821 819
 		{
822 820
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
823
-			foreach((array)$selected as $path)
821
+			foreach ((array)$selected as $path)
824 822
 			{
825 823
 				if (Vfs::isProtectedDir($path))
826 824
 				{
827 825
 					$errs++;
828
-					return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path));
826
+					return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path));
829 827
 				}
830 828
 			}
831 829
 			// now we use find to loop through all files and dirs: (selected only contains dirs now)
832 830
 			// - depth=true to get first the files and then the dir containing it
833 831
 			// - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs
834 832
 			// - show-deleted=false to not (finally) deleted versioned files
835
-			foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path)
833
+			foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path)
836 834
 			{
837
-				if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0))
835
+				if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0))
838 836
 				{
839 837
 					++$dirs;
840 838
 				}
@@ -850,13 +848,13 @@  discard block
 block discarded – undo
850 848
 		}
851 849
 		if ($errs)
852 850
 		{
853
-			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files);
851
+			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files);
854 852
 		}
855 853
 		if ($dirs)
856 854
 		{
857
-			return lang('%1 directories and %2 files deleted.',$dirs,$files);
855
+			return lang('%1 directories and %2 files deleted.', $dirs, $files);
858 856
 		}
859
-		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files);
857
+		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files);
860 858
 	}
861 859
 
862 860
 	/**
@@ -871,37 +869,37 @@  discard block
 block discarded – undo
871 869
 		if (!$query['csv_export'])
872 870
 		{
873 871
 			Api\Cache::setSession('filemanager', 'index',
874
-				array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions'))));
872
+				array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
875 873
 		}
876
-		if(!$query['path']) $query['path'] = static::get_home_dir();
874
+		if (!$query['path']) $query['path'] = static::get_home_dir();
877 875
 
878 876
 		// Change template to match selected view
879
-		if($query['view'])
877
+		if ($query['view'])
880 878
 		{
881 879
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile');
882 880
 
883 881
 			// Store as preference but only for index, not home
884
-			if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
882
+			if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
885 883
 			{
886
-				$GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']);
884
+				$GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']);
887 885
 				$GLOBALS['egw']->preferences->save_repository();
888 886
 			}
889 887
 		}
890 888
 		// be tolerant with (in previous versions) not correct urlencoded pathes
891
-		if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path'])))
889
+		if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path'])))
892 890
 		{
893 891
 			$query['path'] = urldecode($query['path']);
894 892
 		}
895
-		if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE))
893
+		if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE))
896 894
 		{
897 895
 			// only redirect, if it would be to some other location, gives redirect-loop otherwise
898 896
 			if ($query['path'] != ($path = static::get_home_dir()))
899 897
 			{
900 898
 				// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
901 899
 				// an appropriate message
902
-				Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
900
+				Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index',
903 901
 					'path' => $path,
904
-					'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])),
902
+					'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])),
905 903
 					'ajax' => 'true'
906 904
 				));
907 905
 			}
@@ -909,35 +907,35 @@  discard block
 block discarded – undo
909 907
 			return 0;
910 908
 		}
911 909
 		$rows = $dir_is_writable = array();
912
-		if($query['searchletter'] && !empty($query['search']))
910
+		if ($query['searchletter'] && !empty($query['search']))
913 911
 		{
914
-			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
912
+			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
915 913
 			if ($query['searchletter'] == strtolower($query['search'][0]))
916 914
 			{
917
-				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'.
918
-					str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i';
915
+				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'.
916
+					str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i';
919 917
 			}
920 918
 		}
921 919
 		elseif ($query['searchletter'])
922 920
 		{
923 921
 			$namefilter = '/^'.$query['searchletter'].'/i';
924 922
 		}
925
-		elseif(!empty($query['search']))
923
+		elseif (!empty($query['search']))
926 924
 		{
927
-			$namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
925
+			$namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
928 926
 		}
929 927
 
930 928
 		// Re-map so 'No filters' favorite ('') is depth 1
931 929
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
932 930
 
933 931
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
934
-		if($filter == 5) $maxdepth = 2;
932
+		if ($filter == 5) $maxdepth = 2;
935 933
 		$n = 0;
936 934
 		$vfs_options = array(
937 935
 			'mindepth' => 1,
938 936
 			'maxdepth' => $maxdepth,
939 937
 			'dirsontop' => $filter <= 1,
940
-			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'),
938
+			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'),
941 939
 			'order' => $query['order'], 'sort' => $query['sort'],
942 940
 			'limit' => (int)$query['num_rows'].','.(int)$query['start'],
943 941
 			'need_mime' => true,
@@ -945,11 +943,11 @@  discard block
 block discarded – undo
945 943
 			'hidden' => $filter == 3,
946 944
 			'follow' => $filter == 5,
947 945
 		);
948
-		if($query['col_filter']['mime'])
946
+		if ($query['col_filter']['mime'])
949 947
 		{
950 948
 			$vfs_options['mime'] = $query['col_filter']['mime'];
951 949
 		}
952
-		foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row)
950
+		foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row)
953 951
 		{
954 952
 			//echo $path; _debug_array($row);
955 953
 
@@ -967,7 +965,7 @@  discard block
 block discarded – undo
967 965
 
968 966
 				$row['class'] .= 'isDir ';
969 967
 				$row['is_dir'] = 1;
970
-				if(!$dir_is_writable[$path])
968
+				if (!$dir_is_writable[$path])
971 969
 				{
972 970
 					$row['class'] .= 'noEdit ';
973 971
 				}
@@ -979,32 +977,32 @@  discard block
 block discarded – undo
979 977
 
980 978
 			$row['class'] .= !$dir_is_writable[$dir] ? 'noDelete' : '';
981 979
 			$row['download_url'] = Vfs::download_url($path);
982
-			$row['gid'] = -abs($row['gid']);	// gid are positive, but we use negagive account_id for groups internal
980
+			$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
983 981
 
984 982
 			$rows[++$n] = $row;
985 983
 			$path2n[$path] = $n;
986 984
 		}
987 985
 		// query comments and cf's for the displayed rows
988
-		$cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
986
+		$cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
989 987
 
990 988
 		// Always include comment in tiles
991
-		if($query['view'] == 'tile')
989
+		if ($query['view'] == 'tile')
992 990
 		{
993 991
 			$cols_to_show[] = 'comment';
994 992
 		}
995
-		$all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#';
996
-		if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) &&
993
+		$all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#';
994
+		if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) &&
997 995
 			($path2props = Vfs::propfind(array_keys($path2n))))
998 996
 		{
999
-			foreach($path2props as $path => $props)
997
+			foreach ($path2props as $path => $props)
1000 998
 			{
1001
-				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
1002
-				$row =& $rows[$path2n[$path]];
1003
-				if ( !is_array($props) ) continue;
1004
-				foreach($props as $prop)
999
+				unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2
1000
+				$row = & $rows[$path2n[$path]];
1001
+				if (!is_array($props)) continue;
1002
+				foreach ($props as $prop)
1005 1003
 				{
1006
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
1007
-					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
1004
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue;
1005
+					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...';
1008 1006
 				}
1009 1007
 			}
1010 1008
 		}
@@ -1016,7 +1014,7 @@  discard block
 block discarded – undo
1016 1014
 		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager')
1017 1015
 		{
1018 1016
 			// we need our app.css file
1019
-			if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
1017
+			if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
1020 1018
 			{
1021 1019
 				$css_file = '/filemanager/templates/default/app.css';
1022 1020
 			}
@@ -1032,7 +1030,7 @@  discard block
 block discarded – undo
1032 1030
 	 * @param array $content
1033 1031
 	 * @param string $msg
1034 1032
 	 */
1035
-	function file(array $content=null,$msg='')
1033
+	function file(array $content = null, $msg = '')
1036 1034
 	{
1037 1035
 		$tpl = new Etemplate('filemanager.file');
1038 1036
 
@@ -1042,9 +1040,9 @@  discard block
 block discarded – undo
1042 1040
 			{
1043 1041
 				$msg .= $_GET['msg'];
1044 1042
 			}
1045
-			if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) ||	// ?, # need to stay encoded!
1043
+			if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded!
1046 1044
 				// actions enclose pathes containing comma with "
1047
-				($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) ||
1045
+				($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) ||
1048 1046
 				!($stat = Vfs::lstat($path)))
1049 1047
 			{
1050 1048
 				$msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat);
@@ -1057,10 +1055,10 @@  discard block
 block discarded – undo
1057 1055
 				$content['path'] = $path;
1058 1056
 				$content['hsize'] = Vfs::hsize($stat['size']);
1059 1057
 				$content['mime'] = Vfs::mime_content_type($path);
1060
-				$content['gid'] *= -1;	// our widgets use negative gid's
1058
+				$content['gid'] *= -1; // our widgets use negative gid's
1061 1059
 				if (($props = Vfs::propfind($path)))
1062 1060
 				{
1063
-					foreach($props as $prop)
1061
+					foreach ($props as $prop)
1064 1062
 					{
1065 1063
 						$content[$prop['name']] = $prop['val'];
1066 1064
 					}
@@ -1073,9 +1071,9 @@  discard block
 block discarded – undo
1073 1071
 			$content['tabs'] = $_GET['tabs'];
1074 1072
 			if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path)))
1075 1073
 			{
1076
-				$content['perms']['executable'] = (int)!!($content['mode'] & 0111);
1074
+				$content['perms']['executable'] = (int)!!($content['mode']&0111);
1077 1075
 				$mask = 6;
1078
-				if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000)
1076
+				if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000)
1079 1077
 				{
1080 1078
 					$content['text_content'] = file_get_contents(Vfs::PREFIX.$path);
1081 1079
 				}
@@ -1085,19 +1083,19 @@  discard block
 block discarded – undo
1085 1083
 				//currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201);
1086 1084
 				$mask = 7;
1087 1085
 			}
1088
-			foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift)
1086
+			foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift)
1089 1087
 			{
1090
-				$content['perms'][$name] = ($content['mode'] >> $shift) & $mask;
1088
+				$content['perms'][$name] = ($content['mode'] >> $shift)&$mask;
1091 1089
 			}
1092
-			$content['is_owner'] = Vfs::has_owner_rights($path,$content);
1090
+			$content['is_owner'] = Vfs::has_owner_rights($path, $content);
1093 1091
 		}
1094 1092
 		else
1095 1093
 		{
1096 1094
 			//_debug_array($content);
1097
-			$path =& $content['path'];
1095
+			$path = & $content['path'];
1098 1096
 
1099 1097
 			list($button) = @each($content['button']); unset($content['button']);
1100
-			if(!$button && $content['sudo'])
1098
+			if (!$button && $content['sudo'])
1101 1099
 			{
1102 1100
 				// Button to stop sudo is not in button namespace
1103 1101
 				$button = 'sudo';
@@ -1106,21 +1104,21 @@  discard block
 block discarded – undo
1106 1104
 			// need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field
1107 1105
 			if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user'])
1108 1106
 			{
1109
-				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ?
1107
+				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ?
1110 1108
 					lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ?
1111 1109
 					lang('Wrong username or password!') : lang('Root access stopped.'));
1112 1110
 				unset($content['sudo']);
1113 1111
 				$content['is_owner'] = Vfs::has_owner_rights($path);
1114 1112
 			}
1115
-			if (in_array($button,array('save','apply')))
1113
+			if (in_array($button, array('save', 'apply')))
1116 1114
 			{
1117 1115
 				$props = array();
1118 1116
 				$perm_changed = $perm_failed = 0;
1119
-				foreach($content['old'] as $name => $old_value)
1117
+				foreach ($content['old'] as $name => $old_value)
1120 1118
 				{
1121 1119
 					if (isset($content[$name]) && ($old_value != $content[$name] ||
1122 1120
 						// do not check for modification, if modify_subs is checked!
1123
-						$content['modify_subs'] && in_array($name,array('uid','gid','perms'))) &&
1121
+						$content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) &&
1124 1122
 						($name != 'uid' || Vfs::$is_root))
1125 1123
 					{
1126 1124
 						if ($name == 'name')
@@ -1134,23 +1132,23 @@  discard block
 block discarded – undo
1134 1132
 							$to = Vfs::concat($dir, $content['name']);
1135 1133
 							if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to)
1136 1134
 							{
1137
-								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1138
-									lang('To overwrite the existing file store again.',lang($button)));
1135
+								$tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'.
1136
+									lang('To overwrite the existing file store again.', lang($button)));
1139 1137
 								$content['confirm_overwrite'] = $to;
1140 1138
 								if ($button == 'save') $button = 'apply';
1141 1139
 								continue;
1142 1140
 							}
1143
-							if (Vfs::rename($path,$to))
1141
+							if (Vfs::rename($path, $to))
1144 1142
 							{
1145
-								$msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' ';
1143
+								$msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' ';
1146 1144
 								$content['old']['name'] = $content[$name];
1147 1145
 								$path = $to;
1148
-								$content['mime'] = Api\MimeMagic::filename2mime($path);	// recheck mime type
1149
-								$refresh_path = Vfs::dirname($path);	// for renames, we have to refresh the parent
1146
+								$content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type
1147
+								$refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent
1150 1148
 							}
1151 1149
 							else
1152 1150
 							{
1153
-								$msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' ';
1151
+								$msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' ';
1154 1152
 								if (Vfs::deny_script($to))
1155 1153
 								{
1156 1154
 									$msg .= lang('You are NOT allowed to upload a script!').' ';
@@ -1170,7 +1168,7 @@  discard block
 block discarded – undo
1170 1168
 									'val'	=> (!empty($content[$name]) ? $content[$name] : null),
1171 1169
 								),
1172 1170
 							);
1173
-							if (Vfs::proppatch($path,$mergeprop))
1171
+							if (Vfs::proppatch($path, $mergeprop))
1174 1172
 							{
1175 1173
 								$content['old'][$name] = $content[$name];
1176 1174
 								$msg .= lang('Setting for document merge saved.');
@@ -1182,22 +1180,22 @@  discard block
 block discarded – undo
1182 1180
 						}
1183 1181
 						else
1184 1182
 						{
1185
-							static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
1186
-							$cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]);
1183
+							static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod');
1184
+							$cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]);
1187 1185
 							$value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name];
1188 1186
 							if ($content['modify_subs'])
1189 1187
 							{
1190 1188
 								if ($name == 'perms')
1191 1189
 								{
1192
-									$changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value));
1193
-									$changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666));	// no execute for files
1190
+									$changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value));
1191
+									$changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files
1194 1192
 								}
1195 1193
 								else
1196 1194
 								{
1197
-									$changed = Vfs::find($path,null,$cmd,array($value));
1195
+									$changed = Vfs::find($path, null, $cmd, array($value));
1198 1196
 								}
1199 1197
 								$ok = $failed = 0;
1200
-								foreach($changed as &$r)
1198
+								foreach ($changed as &$r)
1201 1199
 								{
1202 1200
 									if ($r)
1203 1201
 									{
@@ -1210,32 +1208,32 @@  discard block
 block discarded – undo
1210 1208
 								}
1211 1209
 								if ($ok && !$failed)
1212 1210
 								{
1213
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1211
+									if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren'));
1214 1212
 									$content['old'][$name] = $content[$name];
1215 1213
 								}
1216
-								elseif($failed)
1214
+								elseif ($failed)
1217 1215
 								{
1218
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1219
-										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1216
+									if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren').
1217
+										($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : ''));
1220 1218
 								}
1221 1219
 							}
1222
-							elseif (call_user_func_array($cmd,array($path,$value)))
1220
+							elseif (call_user_func_array($cmd, array($path, $value)))
1223 1221
 							{
1224
-								$msg .= lang('Permissions of %1 changed.',$path);
1222
+								$msg .= lang('Permissions of %1 changed.', $path);
1225 1223
 								$content['old'][$name] = $content[$name];
1226 1224
 							}
1227 1225
 							else
1228 1226
 							{
1229
-								$msg .= lang('Failed to change permissions of %1!',$path);
1227
+								$msg .= lang('Failed to change permissions of %1!', $path);
1230 1228
 							}
1231 1229
 						}
1232 1230
 					}
1233 1231
 				}
1234 1232
 				if ($props)
1235 1233
 				{
1236
-					if (Vfs::proppatch($path,$props))
1234
+					if (Vfs::proppatch($path, $props))
1237 1235
 					{
1238
-						foreach($props as $prop)
1236
+						foreach ($props as $prop)
1239 1237
 						{
1240 1238
 							$content['old'][$prop['name']] = $prop['val'];
1241 1239
 						}
@@ -1252,8 +1250,8 @@  discard block
 block discarded – undo
1252 1250
 				if ($content['eacl']['delete'])
1253 1251
 				{
1254 1252
 					list($ino_owner) = each($content['eacl']['delete']);
1255
-					list(, $owner) = explode('-',$ino_owner,2);	// $owner is a group and starts with a minus!
1256
-					$msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1253
+					list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus!
1254
+					$msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1257 1255
 				}
1258 1256
 				elseif ($button == 'eacl')
1259 1257
 				{
@@ -1263,7 +1261,7 @@  discard block
 block discarded – undo
1263 1261
 					}
1264 1262
 					else
1265 1263
 					{
1266
-						$msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ?
1264
+						$msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ?
1267 1265
 							lang('ACL added.') : lang('Error adding the ACL!');
1268 1266
 					}
1269 1267
 				}
@@ -1273,7 +1271,7 @@  discard block
 block discarded – undo
1273 1271
 		}
1274 1272
 		if ($content['is_link'] && !Vfs::stat($path))
1275 1273
 		{
1276
-			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']);
1274
+			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']);
1277 1275
 		}
1278 1276
 		$content['link'] = Egw::link(Vfs::download_url($path));
1279 1277
 		$content['icon'] = Vfs::mime_icon($content['mime']);
@@ -1282,11 +1280,11 @@  discard block
 block discarded – undo
1282 1280
 		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1283 1281
 		// only owner can change group & perms
1284 1282
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1285
-			Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs
1283
+			Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs') || // no uid, gid or perms in oldvfs
1286 1284
 				 !Vfs::is_writable($path))
1287 1285
 		{
1288 1286
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1289
-			foreach($content['perms'] as $name => $value)
1287
+			foreach ($content['perms'] as $name => $value)
1290 1288
 			{
1291 1289
 				$readonlys['perms['.$name.']'] = true;
1292 1290
 			}
@@ -1305,38 +1303,38 @@  discard block
 block discarded – undo
1305 1303
 		}
1306 1304
 		elseif (!Vfs::is_writable($path))
1307 1305
 		{
1308
-			foreach($cfs as $name => $data)
1306
+			foreach ($cfs as $name => $data)
1309 1307
 			{
1310 1308
 				$readonlys['#'.$name] = true;
1311 1309
 			}
1312 1310
 		}
1313
-		$readonlys['tabs']['filemanager.file.eacl'] = true;	// eacl off by default
1311
+		$readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default
1314 1312
 		if ($content['is_dir'])
1315 1313
 		{
1316
-			$readonlys['tabs']['filemanager.file.preview'] = true;	// no preview tab for dirs
1317
-			$sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1314
+			$readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs
1315
+			$sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1318 1316
 				7 => lang('Display and modification of content'),
1319 1317
 				5 => lang('Display of content'),
1320 1318
 				0 => lang('No access'),
1321 1319
 			);
1322
-			if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false &&	// backend supports eacl
1320
+			if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl
1323 1321
 				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)	// leave eACL tab disabled for sharing
1324 1322
 			{
1325
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1326
-				foreach($content['eacl'] as &$eacl)
1323
+				unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again
1324
+				foreach ($content['eacl'] as &$eacl)
1327 1325
 				{
1328
-					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
1326
+					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/');
1329 1327
 					$readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] ||
1330 1328
 						$eacl['path'] != $content['path'] || !$content['is_owner'];
1331 1329
 				}
1332
-				array_unshift($content['eacl'],false);	// make the keys start with 1, not 0
1330
+				array_unshift($content['eacl'], false); // make the keys start with 1, not 0
1333 1331
 				$content['eacl']['owner'] = 0;
1334 1332
 				$content['eacl']['rights'] = 5;
1335 1333
 			}
1336 1334
 		}
1337 1335
 		else
1338 1336
 		{
1339
-			$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1337
+			$sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1340 1338
 				6 => lang('Read & write access'),
1341 1339
 				4 => lang('Read access only'),
1342 1340
 				0 => lang('No access'),
@@ -1346,11 +1344,11 @@  discard block
 block discarded – undo
1346 1344
 		// mergeapp
1347 1345
 		$content['mergeapp'] = static::get_mergeapp($path, 'self');
1348 1346
 		$content['mergeapp_parent'] = static::get_mergeapp($path, 'parents');
1349
-		if(!empty($content['mergeapp']))
1347
+		if (!empty($content['mergeapp']))
1350 1348
 		{
1351 1349
 			$content['mergeapp_effective'] = $content['mergeapp'];
1352 1350
 		}
1353
-		elseif(!empty($content['mergeapp_parent']))
1351
+		elseif (!empty($content['mergeapp_parent']))
1354 1352
 		{
1355 1353
 			$content['mergeapp_effective'] = $content['mergeapp_parent'];
1356 1354
 		}
@@ -1362,7 +1360,7 @@  discard block
 block discarded – undo
1362 1360
 		$mergeapp_list = Link::app_list('merge');
1363 1361
 		unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list
1364 1362
 		$mergeapp_empty = !empty($content['mergeapp_parent'])
1365
-			? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
1363
+			? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : '';
1366 1364
 		$sel_options['mergeapp'] = array(''	=> $mergeapp_empty);
1367 1365
 		$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
1368 1366
 		// mergeapp other gui options
@@ -1379,7 +1377,7 @@  discard block
 block discarded – undo
1379 1377
 				'comment' => (string)$content['comment'],
1380 1378
 				'mergeapp' => $content['mergeapp']
1381 1379
 			);
1382
-			if ($cfs) foreach($cfs as $name => $data)
1380
+			if ($cfs) foreach ($cfs as $name => $data)
1383 1381
 			{
1384 1382
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1385 1383
 			}
@@ -1387,31 +1385,31 @@  discard block
 block discarded – undo
1387 1385
 		if (Vfs::$is_root)
1388 1386
 		{
1389 1387
 			$tpl->setElementAttribute('sudouser', 'label', 'Logout');
1390
-			$tpl->setElementAttribute('sudouser', 'help','Log out as superuser');
1388
+			$tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser');
1391 1389
 			// Need a more complex submit because button type is buttononly, which doesn't submit
1392
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")');
1390
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")');
1393 1391
 
1394 1392
 		}
1395 1393
 		elseif ($button == 'sudo')
1396 1394
 		{
1397 1395
 			$tpl->setElementAttribute('sudouser', 'label', 'Superuser');
1398
-			$tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights');
1399
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")');
1396
+			$tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights');
1397
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")');
1400 1398
 		}
1401 1399
 		else if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id']))
1402 1400
 		{
1403 1401
 			// Just hide sudo for anonymous users
1404 1402
 			$readonlys['sudouser'] = true;
1405 1403
 		}
1406
-		if (($extra_tabs = Vfs::getExtraInfo($path,$content)))
1404
+		if (($extra_tabs = Vfs::getExtraInfo($path, $content)))
1407 1405
 		{
1408 1406
 			// add to existing tabs in template
1409 1407
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1410 1408
 
1411
-			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1409
+			$tabs = & $tpl->getElementAttribute('tabs', 'tabs');
1412 1410
 			if (true) $tabs = array();
1413 1411
 
1414
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1412
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1415 1413
 			{
1416 1414
 				$tabs[] = array(
1417 1415
 					'label' =>	$extra_tab['label'],
@@ -1434,7 +1432,7 @@  discard block
 block discarded – undo
1434 1432
 		Framework::window_focus();
1435 1433
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path);
1436 1434
 
1437
-		$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
1435
+		$tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2);
1438 1436
 	}
1439 1437
 
1440 1438
 	/**
@@ -1456,7 +1454,7 @@  discard block
 block discarded – undo
1456 1454
 	 * @param string $dir=null current directory
1457 1455
 	 * @see static::action()
1458 1456
 	 */
1459
-	public static function ajax_action($action, $selected, $dir=null, $props=null)
1457
+	public static function ajax_action($action, $selected, $dir = null, $props = null)
1460 1458
 	{
1461 1459
 		// do we have root rights, need to run here too, as method is static and therefore does NOT run __construct
1462 1460
 		if (Api\Cache::getSession('filemanager', 'is_root'))
@@ -1475,15 +1473,15 @@  discard block
 block discarded – undo
1475 1473
 
1476 1474
 		if (!isset($dir)) $dir = array_pop($selected);
1477 1475
 
1478
-		switch($action)
1476
+		switch ($action)
1479 1477
 		{
1480 1478
 			case 'upload':
1481 1479
 				$script_error = 0;
1482
-				foreach($selected as $tmp_name => &$data)
1480
+				foreach ($selected as $tmp_name => &$data)
1483 1481
 				{
1484 1482
 					$path = Vfs::concat($dir, Vfs::encodePathComponent($data['name']));
1485 1483
 
1486
-					if(Vfs::deny_script($path))
1484
+					if (Vfs::deny_script($path))
1487 1485
 					{
1488 1486
 						if (!isset($script_error))
1489 1487
 						{
@@ -1505,7 +1503,7 @@  discard block
 block discarded – undo
1505 1503
 					{
1506 1504
 						if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
1507 1505
 						{
1508
-							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
1506
+							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name);
1509 1507
 						}
1510 1508
 						else
1511 1509
 						{
@@ -1564,16 +1562,16 @@  discard block
 block discarded – undo
1564 1562
 			case 'link':
1565 1563
 				// First upload
1566 1564
 				$arr = static::ajax_action('upload', $selected, $dir, $props);
1567
-				$app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
1565
+				$app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true);
1568 1566
 
1569
-				foreach($arr['uploaded'] as $file)
1567
+				foreach ($arr['uploaded'] as $file)
1570 1568
 				{
1571
-					$target=Vfs::concat($dir,Vfs::encodePathComponent($file['name']));
1569
+					$target = Vfs::concat($dir, Vfs::encodePathComponent($file['name']));
1572 1570
 					if (Vfs::file_exists($target) && $app_dir)
1573 1571
 					{
1574 1572
 						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1575 1573
 						error_log("Symlinking $target to $app_dir");
1576
-						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1574
+						Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name'])));
1577 1575
 					}
1578 1576
 				}
1579 1577
 				// Must return to avoid adding to $response again
@@ -1595,7 +1593,7 @@  discard block
 block discarded – undo
1595 1593
 	 */
1596 1594
 	private function perms2mode(array $perms)
1597 1595
 	{
1598
-		$mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other'];
1596
+		$mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other'];
1599 1597
 		if ($mode['executable'])
1600 1598
 		{
1601 1599
 			$mode |= 0111;
@@ -1612,7 +1610,7 @@  discard block
 block discarded – undo
1612 1610
 	 *
1613 1611
 	 * @param array $content
1614 1612
 	 */
1615
-	function editor($content=null)
1613
+	function editor($content = null)
1616 1614
 	{
1617 1615
 		$tmpl = new Etemplate('filemanager.editor');
1618 1616
 		$path = $_GET['path'];
@@ -1630,13 +1628,13 @@  discard block
 block discarded – undo
1630 1628
 		Api\Framework::includeCSS('/api/js/webodf/collab/app/resources/app.css');
1631 1629
 		Api\Framework::includeCSS('/api/js/webodf/collab/wodocollabpane.css');
1632 1630
 		Api\Framework::includeCSS('/api/js/webodf/collab/wodotexteditor.css');
1633
-		Api\Framework::includeJS('/filemanager/js/collab.js',null, 'filemanager');
1631
+		Api\Framework::includeJS('/filemanager/js/collab.js', null, 'filemanager');
1634 1632
 
1635 1633
 		if (!$content)
1636 1634
 		{
1637 1635
 			if ($download_url)
1638 1636
 			{
1639
-				$content['es_id'] = md5 ($download_url);
1637
+				$content['es_id'] = md5($download_url);
1640 1638
 				$content['file_path'] = $path;
1641 1639
 			}
1642 1640
 			else
@@ -1654,7 +1652,7 @@  discard block
 block discarded – undo
1654 1652
 		}
1655 1653
 		$tmpl->setElementAttribute('tools', 'actions', $actions);
1656 1654
 		$preserve = $content;
1657
-		$tmpl->exec('filemanager.filemanager_ui.editor',$content,array(),array(),$preserve,2);
1655
+		$tmpl->exec('filemanager.filemanager_ui.editor', $content, array(), array(), $preserve, 2);
1658 1656
 	}
1659 1657
 
1660 1658
 	/**
@@ -1665,7 +1663,7 @@  discard block
 block discarded – undo
1665 1663
 	static function getActions_edit()
1666 1664
 	{
1667 1665
 		$group = 0;
1668
-		$actions = array (
1666
+		$actions = array(
1669 1667
 			'save' => array(
1670 1668
 				'caption' => 'Save',
1671 1669
 				'icon' => 'apply',
Please login to merge, or discard this patch.
Braces   +144 added lines, -37 removed lines patch added patch discarded remove patch
@@ -88,7 +88,10 @@  discard block
 block discarded – undo
88 88
 			// search for plugins with additional filemanager views
89 89
 			foreach(Api\Hooks::process('filemanager_views') as $views)
90 90
 			{
91
-				if (is_array($views)) static::$views += $views;
91
+				if (is_array($views))
92
+				{
93
+					static::$views += $views;
94
+				}
92 95
 			}
93 96
 			static::$views_init = true;
94 97
 		}
@@ -286,7 +289,8 @@  discard block
 block discarded – undo
286 289
 			)
287 290
 		);
288 291
 
289
-		if (isset($GLOBALS['egw_info']['user']['apps']['mail'])) {
292
+		if (isset($GLOBALS['egw_info']['user']['apps']['mail']))
293
+		{
290 294
 			foreach(Vfs\Sharing::$modes as $mode => $data)
291 295
 			{
292 296
 				$actions['share']['children']['mail_'.$mode] = array(
@@ -397,7 +401,10 @@  discard block
 block discarded – undo
397 401
 			$content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view'];
398 402
 			$content['nm']['placeholder_actions'] = array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink');
399 403
 
400
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
404
+			if (isset($_GET['msg']))
405
+			{
406
+				$msg = $_GET['msg'];
407
+			}
401 408
 
402 409
 			// Blank favorite set via GET needs special handling for path
403 410
 			if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank')
@@ -431,7 +438,10 @@  discard block
 block discarded – undo
431 438
 				// reset lettersearch as it confuses users (they think the dir is empty)
432 439
 				$content['nm']['searchletter'] = false;
433 440
 				// switch recusive display off
434
-				if (!$content['nm']['filter']) $content['nm']['filter'] = '';
441
+				if (!$content['nm']['filter'])
442
+				{
443
+					$content['nm']['filter'] = '';
444
+				}
435 445
 			}
436 446
 		}
437 447
 		$view = static::get_view();
@@ -480,37 +490,70 @@  discard block
 block discarded – undo
480 490
 	{
481 491
 		$tpl = new Etemplate('filemanager.index');
482 492
 
483
-		if($msg) Framework::message($msg);
493
+		if($msg)
494
+		{
495
+			Framework::message($msg);
496
+		}
484 497
 
485 498
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
486 499
 		{
487 500
 			if ($content['nm']['action'])
488 501
 			{
489 502
 				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
490
-				if($msg) Framework::message($msg);
503
+				if($msg)
504
+				{
505
+					Framework::message($msg);
506
+				}
491 507
 
492 508
 				// clean up after action
493 509
 				unset($content['nm']['selected']);
494 510
 				// 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
495
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
496
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
497
-				if (isset($content['nm_action'])) unset($content['nm_action']);
511
+				if (isset($content['nm']['action']))
512
+				{
513
+					unset($content['nm']['action']);
514
+				}
515
+				if (isset($content['nm']['nm_action']))
516
+				{
517
+					unset($content['nm']['nm_action']);
518
+				}
519
+				if (isset($content['nm_action']))
520
+				{
521
+					unset($content['nm_action']);
522
+				}
498 523
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
499
-				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
524
+				if (isset($content['nm']['rows']['delete']))
525
+				{
526
+					unset($content['nm']['rows']['delete']);
527
+				}
500 528
 			}
501 529
 			elseif($content['nm']['rows']['delete'])
502 530
 			{
503 531
 				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
504
-				if($msg) Framework::message($msg);
532
+				if($msg)
533
+				{
534
+					Framework::message($msg);
535
+				}
505 536
 
506 537
 				// clean up after action
507 538
 				unset($content['nm']['rows']['delete']);
508 539
 				// reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow
509 540
 				// we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
510
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
511
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
512
-				if (isset($content['nm_action'])) unset($content['nm_action']);
513
-				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
541
+				if (isset($content['nm']['action']))
542
+				{
543
+					unset($content['nm']['action']);
544
+				}
545
+				if (isset($content['nm']['nm_action']))
546
+				{
547
+					unset($content['nm']['nm_action']);
548
+				}
549
+				if (isset($content['nm_action']))
550
+				{
551
+					unset($content['nm_action']);
552
+				}
553
+				if (isset($content['nm']['selected']))
554
+				{
555
+					unset($content['nm']['selected']);
556
+				}
514 557
 			}
515 558
 			unset($content['nm']['rows']);
516 559
 			Api\Cache::setSession('filemanager', 'index',$content['nm']);
@@ -677,9 +720,12 @@  discard block
 block discarded – undo
677 720
 						foreach(Vfs::find($path) as $p)
678 721
 						{
679 722
 							$to = $dir.substr($p,$len);
680
-							if ($to == $p)	// cant copy into itself!
723
+							if ($to == $p)
724
+							{
725
+								// cant copy into itself!
681 726
 							{
682 727
 								++$errs;
728
+							}
683 729
 								continue;
684 730
 							}
685 731
 							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
@@ -734,7 +780,10 @@  discard block
 block discarded – undo
734 780
 							continue;
735 781
 						}
736 782
 					}
737
-					if ($target[0] != '/') $target = Vfs::concat($dir, $target);
783
+					if ($target[0] != '/')
784
+					{
785
+						$target = Vfs::concat($dir, $target);
786
+					}
738 787
 					if (!Vfs::stat($target))
739 788
 					{
740 789
 						return lang('Link target %1 not found!', Vfs::decodePath($target));
@@ -777,10 +826,16 @@  discard block
 block discarded – undo
777 826
 				switch($action)
778 827
 				{
779 828
 					case 'document':
780
-						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
829
+						if (!$settings)
830
+						{
831
+							$settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
832
+						}
781 833
 						$document_merge = new filemanager_merge(Vfs::decodePath($dir));
782 834
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
783
-						if($msg) return $msg;
835
+						if($msg)
836
+						{
837
+							return $msg;
838
+						}
784 839
 						$errs = count($selected);
785 840
 						return false;
786 841
 				}
@@ -817,7 +872,9 @@  discard block
 block discarded – undo
817 872
 				unset($selected[$key]);
818 873
 			}
819 874
 		}
820
-		if ($selected)	// somethings left to delete
875
+		if ($selected)
876
+		{
877
+			// somethings left to delete
821 878
 		{
822 879
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
823 880
 			foreach((array)$selected as $path)
@@ -825,6 +882,7 @@  discard block
 block discarded – undo
825 882
 				if (Vfs::isProtectedDir($path))
826 883
 				{
827 884
 					$errs++;
885
+		}
828 886
 					return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path));
829 887
 				}
830 888
 			}
@@ -873,7 +931,10 @@  discard block
 block discarded – undo
873 931
 			Api\Cache::setSession('filemanager', 'index',
874 932
 				array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions'))));
875 933
 		}
876
-		if(!$query['path']) $query['path'] = static::get_home_dir();
934
+		if(!$query['path'])
935
+		{
936
+			$query['path'] = static::get_home_dir();
937
+		}
877 938
 
878 939
 		// Change template to match selected view
879 940
 		if($query['view'])
@@ -931,7 +992,10 @@  discard block
 block discarded – undo
931 992
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
932 993
 
933 994
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
934
-		if($filter == 5) $maxdepth = 2;
995
+		if($filter == 5)
996
+		{
997
+			$maxdepth = 2;
998
+		}
935 999
 		$n = 0;
936 1000
 		$vfs_options = array(
937 1001
 			'mindepth' => 1,
@@ -1000,10 +1064,16 @@  discard block
 block discarded – undo
1000 1064
 			{
1001 1065
 				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
1002 1066
 				$row =& $rows[$path2n[$path]];
1003
-				if ( !is_array($props) ) continue;
1067
+				if ( !is_array($props) )
1068
+				{
1069
+					continue;
1070
+				}
1004 1071
 				foreach($props as $prop)
1005 1072
 				{
1006
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
1073
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show))
1074
+					{
1075
+						continue;
1076
+					}
1007 1077
 					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
1008 1078
 				}
1009 1079
 			}
@@ -1128,7 +1198,10 @@  discard block
 block discarded – undo
1128 1198
 							if (!($dir = Vfs::dirname($path)))
1129 1199
 							{
1130 1200
 								$msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false";
1131
-								if ($button == 'save') $button = 'apply';
1201
+								if ($button == 'save')
1202
+								{
1203
+									$button = 'apply';
1204
+								}
1132 1205
 								continue;
1133 1206
 							}
1134 1207
 							$to = Vfs::concat($dir, $content['name']);
@@ -1137,7 +1210,10 @@  discard block
 block discarded – undo
1137 1210
 								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1138 1211
 									lang('To overwrite the existing file store again.',lang($button)));
1139 1212
 								$content['confirm_overwrite'] = $to;
1140
-								if ($button == 'save') $button = 'apply';
1213
+								if ($button == 'save')
1214
+								{
1215
+									$button = 'apply';
1216
+								}
1141 1217
 								continue;
1142 1218
 							}
1143 1219
 							if (Vfs::rename($path,$to))
@@ -1210,13 +1286,19 @@  discard block
 block discarded – undo
1210 1286
 								}
1211 1287
 								if ($ok && !$failed)
1212 1288
 								{
1213
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1289
+									if(!$perm_changed++)
1290
+									{
1291
+										$msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1292
+									}
1214 1293
 									$content['old'][$name] = $content[$name];
1215 1294
 								}
1216 1295
 								elseif($failed)
1217 1296
 								{
1218
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1297
+									if(!$perm_failed++)
1298
+									{
1299
+										$msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1219 1300
 										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1301
+									}
1220 1302
 								}
1221 1303
 							}
1222 1304
 							elseif (call_user_func_array($cmd,array($path,$value)))
@@ -1269,7 +1351,10 @@  discard block
 block discarded – undo
1269 1351
 				}
1270 1352
 			}
1271 1353
 			Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*');
1272
-			if ($button == 'save') Framework::window_close();
1354
+			if ($button == 'save')
1355
+			{
1356
+				Framework::window_close();
1357
+			}
1273 1358
 		}
1274 1359
 		if ($content['is_link'] && !Vfs::stat($path))
1275 1360
 		{
@@ -1279,13 +1364,19 @@  discard block
 block discarded – undo
1279 1364
 		$content['icon'] = Vfs::mime_icon($content['mime']);
1280 1365
 		$content['msg'] = $msg;
1281 1366
 
1282
-		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1367
+		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid'])
1368
+		{
1369
+			$content['ro_uid_root'] = 'root';
1370
+		}
1283 1371
 		// only owner can change group & perms
1284 1372
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1285 1373
 			Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs
1286 1374
 				 !Vfs::is_writable($path))
1287 1375
 		{
1288
-			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1376
+			if (!$content['gid'])
1377
+			{
1378
+				$content['ro_gid_root'] = 'root';
1379
+			}
1289 1380
 			foreach($content['perms'] as $name => $value)
1290 1381
 			{
1291 1382
 				$readonlys['perms['.$name.']'] = true;
@@ -1320,9 +1411,13 @@  discard block
 block discarded – undo
1320 1411
 				0 => lang('No access'),
1321 1412
 			);
1322 1413
 			if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false &&	// backend supports eacl
1323
-				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)	// leave eACL tab disabled for sharing
1414
+				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)
1415
+			{
1416
+				// leave eACL tab disabled for sharing
1324 1417
 			{
1325
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1418
+				unset($readonlys['tabs']['filemanager.file.eacl']);
1419
+			}
1420
+			// --> switch the tab on again
1326 1421
 				foreach($content['eacl'] as &$eacl)
1327 1422
 				{
1328 1423
 					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
@@ -1379,10 +1474,13 @@  discard block
 block discarded – undo
1379 1474
 				'comment' => (string)$content['comment'],
1380 1475
 				'mergeapp' => $content['mergeapp']
1381 1476
 			);
1382
-			if ($cfs) foreach($cfs as $name => $data)
1477
+			if ($cfs)
1478
+			{
1479
+				foreach($cfs as $name => $data)
1383 1480
 			{
1384 1481
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1385 1482
 			}
1483
+			}
1386 1484
 		}
1387 1485
 		if (Vfs::$is_root)
1388 1486
 		{
@@ -1409,7 +1507,10 @@  discard block
 block discarded – undo
1409 1507
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1410 1508
 
1411 1509
 			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1412
-			if (true) $tabs = array();
1510
+			if (true)
1511
+			{
1512
+				$tabs = array();
1513
+			}
1413 1514
 
1414 1515
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1415 1516
 			{
@@ -1473,7 +1574,10 @@  discard block
 block discarded – undo
1473 1574
 			'files' => 0,
1474 1575
 		);
1475 1576
 
1476
-		if (!isset($dir)) $dir = array_pop($selected);
1577
+		if (!isset($dir))
1578
+		{
1579
+			$dir = array_pop($selected);
1580
+		}
1477 1581
 
1478 1582
 		switch($action)
1479 1583
 		{
@@ -1571,7 +1675,10 @@  discard block
 block discarded – undo
1571 1675
 					$target=Vfs::concat($dir,Vfs::encodePathComponent($file['name']));
1572 1676
 					if (Vfs::file_exists($target) && $app_dir)
1573 1677
 					{
1574
-						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1678
+						if (!Vfs::file_exists($app_dir))
1679
+						{
1680
+							Vfs::mkdir($app_dir);
1681
+						}
1575 1682
 						error_log("Symlinking $target to $app_dir");
1576 1683
 						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1577 1684
 					}
Please login to merge, or discard this patch.
home/inc/class.home_ui.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@
 block discarded – undo
155 155
 	 * Get a list of the user's portlets, and their associated values & settings, for display
156 156
 	 *
157 157
 	 * Actual portlet content is provided by each portlet.
158
-	 * @param template etemplate so attributes can be set
158
+	 * @param template Etemplate so attributes can be set
159 159
 	 */
160 160
 	protected function get_user_portlets(Etemplate &$template)
161 161
 	{
Please login to merge, or discard this patch.
Braces   +58 added lines, -16 removed lines patch added patch discarded remove patch
@@ -76,7 +76,10 @@  discard block
 block discarded – undo
76 76
 		{
77 77
 			$id = $p_data['id'];
78 78
 
79
-			if(!$id) continue;
79
+			if(!$id)
80
+			{
81
+				continue;
82
+			}
80 83
 			$portlet = $this->get_portlet($id, $p_data, $content, $attrs, true);
81 84
 		}
82 85
 
@@ -135,7 +138,10 @@  discard block
 block discarded – undo
135 138
 			{
136 139
 				foreach($children['children'] as $portlet => $app_portlet)
137 140
 				{
138
-					if(!is_array($app_portlet)) continue;
141
+					if(!is_array($app_portlet))
142
+					{
143
+						continue;
144
+					}
139 145
 					$app_portlet['class'] = $portlet;
140 146
 					$app_portlet['id'] = 'drop_' . $app_portlet['id'];
141 147
 					$app_portlet['onExecute'] = $drop_execute;
@@ -166,14 +172,21 @@  discard block
 block discarded – undo
166 172
 			if(strpos($id,'portlet_') !== 0 || // Not a portlet
167 173
 				in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here
168 174
 				!is_array($context) // Not a valid portlet (probably user deleted a default)
169
-			) continue;
175
+			)
176
+			{
177
+				continue;
178
+			}
170 179
 
171 180
 			$classname = $context['class'];
172 181
 
173 182
 			// Avoid portlets for apps user can't use (eg. from defaults/forced)
174 183
 			list($app,$other) = explode('_',$classname);
175
-			if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other;
176
-			if(!$GLOBALS['egw_info']['user']['apps'][$app]) {
184
+			if(!$GLOBALS['egw_info']['apps'][$app])
185
+			{
186
+				$app .='_'.$other;
187
+			}
188
+			if(!$GLOBALS['egw_info']['user']['apps'][$app])
189
+			{
177 190
 				continue;
178 191
 			}
179 192
 
@@ -189,7 +202,10 @@  discard block
 block discarded – undo
189 202
 			$settings = $portlet->get_properties();
190 203
 			foreach($settings as $key => $setting)
191 204
 			{
192
-				if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
205
+				if(is_array($setting) && !array_key_exists('type',$setting))
206
+				{
207
+					unset($settings[$key]);
208
+				}
193 209
 			}
194 210
 			$settings += $context;
195 211
 			foreach(home_portlet::$common_attributes as $attr)
@@ -229,7 +245,10 @@  discard block
 block discarded – undo
229 245
 	 */
230 246
 	protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false)
231 247
 	{
232
-		if(!$context['class']) $context['class'] = 'home_link_portlet';
248
+		if(!$context['class'])
249
+		{
250
+			$context['class'] = 'home_link_portlet';
251
+		}
233 252
 
234 253
 		// This should be set already, but just in case the execution path
235 254
 		// is different from normal...
@@ -250,7 +269,10 @@  discard block
 block discarded – undo
250 269
 		$settings = $portlet->get_properties();
251 270
 		foreach($settings as $key => $setting)
252 271
 		{
253
-			if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
272
+			if(is_array($setting) && !array_key_exists('type',$setting))
273
+			{
274
+				unset($settings[$key]);
275
+			}
254 276
 		}
255 277
 		$settings += $context;
256 278
 		foreach(home_portlet::$common_attributes as $attr)
@@ -314,7 +336,10 @@  discard block
 block discarded – undo
314 336
 		foreach($sorted_apps as $appname)
315 337
 		{
316 338
 			// If there's already [new] settings, or no preference, skip it
317
-			if($content[$appname]) continue;
339
+			if($content[$appname])
340
+			{
341
+				continue;
342
+			}
318 343
 			$no_pref = true;
319 344
 			foreach($portal_oldvarnames as $varcheck)
320 345
 			{
@@ -349,7 +374,8 @@  discard block
 block discarded – undo
349 374
 	 */
350 375
 	protected function get_portlet_list()
351 376
 	{
352
-		$list = Api\Cache::getTree('home', 'portlet_classes', function() {
377
+		$list = Api\Cache::getTree('home', 'portlet_classes', function()
378
+		{
353 379
 			$list = array();
354 380
 			$classes = array();
355 381
 
@@ -363,9 +389,15 @@  discard block
 block discarded – undo
363 389
 			// Look through all known classes for portlets - for now, they need 'portlet' in the file name
364 390
 			foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
365 391
 			{
366
-				if(in_array($appname, array('phpgwapi', 'felamimail'))) continue;
392
+				if(in_array($appname, array('phpgwapi', 'felamimail')))
393
+				{
394
+					continue;
395
+				}
367 396
 				$files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/');
368
-				if(!$files) continue;
397
+				if(!$files)
398
+				{
399
+					continue;
400
+				}
369 401
 
370 402
 				foreach($files as $entry)
371 403
 				{
@@ -384,7 +416,10 @@  discard block
 block discarded – undo
384 416
 					}
385 417
 				}
386 418
 
387
-				if(!$classes[$appname]) continue;
419
+				if(!$classes[$appname])
420
+				{
421
+					continue;
422
+				}
388 423
 
389 424
 				// Build 'Add' actions for each discovered portlet.
390 425
 				// Portlets from other apps go in sub-actions
@@ -418,7 +453,8 @@  discard block
 block discarded – undo
418 453
 		// Filter list by current user's permissions
419 454
 		foreach(array_keys($list) as $appname)
420 455
 		{
421
-			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
456
+			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps'])))
457
+			{
422 458
 				if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
423 459
 				{
424 460
 					unset($list[$appname]);
@@ -638,7 +674,10 @@  discard block
 block discarded – undo
638 674
 	public static function ajax_set_default($action, $portlet_ids, $group)
639 675
 	{
640 676
 		// Admins only
641
-		if(!$GLOBALS['egw_info']['apps']['admin']) return;
677
+		if(!$GLOBALS['egw_info']['apps']['admin'])
678
+		{
679
+			return;
680
+		}
642 681
 
643 682
 		// Load the appropriate group
644 683
 		if($group)
@@ -701,7 +740,10 @@  discard block
 block discarded – undo
701 740
 		$preferences = $GLOBALS['egw']->preferences;
702 741
 		$preferences->read_repository();
703 742
 		$lang = $preferences->default['common']['lang'];
704
-		if (empty($lang)) $lang = 'en';
743
+		if (empty($lang))
744
+		{
745
+			$lang = 'en';
746
+		}
705 747
 
706 748
 		Api\Translation::add_app('calendar', $lang);
707 749
 		$weekview = lang('Weekview');
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 		$content = array(
50 50
 			'portlets' => $this->get_user_portlets($template)
51 51
 		);
52
-		$template->setElementAttribute('home.index','actions',$this->get_actions());
52
+		$template->setElementAttribute('home.index', 'actions', $this->get_actions());
53 53
 
54 54
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('home');
55 55
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'home';
56 56
 
57 57
 		// Main screen message
58 58
 		Api\Translation::add_app('mainscreen');
59
-		$greeting = Api\Translation::translate('mainscreen_message',false,'');
59
+		$greeting = Api\Translation::translate('mainscreen_message', false, '');
60 60
 
61
-		if($greeting == 'mainscreen_message'|| empty($greeting))
61
+		if ($greeting == 'mainscreen_message' || empty($greeting))
62 62
 		{
63
-			Api\Translation::add_app('mainscreen','en');    // trying the en one
64
-			$greeting = Api\Translation::translate('mainscreen_message',false,'');
63
+			Api\Translation::add_app('mainscreen', 'en'); // trying the en one
64
+			$greeting = Api\Translation::translate('mainscreen_message', false, '');
65 65
 		}
66
-		if(!($greeting == 'mainscreen_message'|| empty($greeting)))
66
+		if (!($greeting == 'mainscreen_message' || empty($greeting)))
67 67
 		{
68 68
 			$content['mainscreen_message'] = $greeting;
69 69
 		}
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 		// Now run the portlets themselves
74 74
 		$attrs = array();
75
-		foreach($content['portlets'] as $portlet => $p_data)
75
+		foreach ($content['portlets'] as $portlet => $p_data)
76 76
 		{
77 77
 			$id = $p_data['id'];
78 78
 
79
-			if(!$id) continue;
79
+			if (!$id) continue;
80 80
 			$portlet = $this->get_portlet($id, $p_data, $content, $attrs, true);
81 81
 		}
82 82
 
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 		$add_portlets = $portlets;
95 95
 		$change_for_add = function(&$add_portlets) use (&$change_for_add)
96 96
 		{
97
-			foreach($add_portlets as $id => &$add)
97
+			foreach ($add_portlets as $id => &$add)
98 98
 			{
99
-				if(is_array($add['children']))
99
+				if (is_array($add['children']))
100 100
 				{
101 101
 					$change_for_add($add['children']);
102 102
 				}
103
-				if($id && !$add['children'])
103
+				if ($id && !$add['children'])
104 104
 				{
105
-					$add['id'] = 'add_' . $id;
105
+					$add['id'] = 'add_'.$id;
106 106
 					$add['class'] = 'add_'.$id;
107 107
 				}
108 108
 			}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 
122 122
 		// Add all known portlets as drop actions too.  If there are multiple matches, there will be a menu
123 123
 		$drop_execute = 'javaScript:app.home.add_from_drop';
124
-		foreach($portlets as $app => &$children)
124
+		foreach ($portlets as $app => &$children)
125 125
 		{
126 126
 			// Home portlets - uses link system, so all apps that support that are accepted
127
-			if(!$children['children'])
127
+			if (!$children['children'])
128 128
 			{
129 129
 				$children['class'] = $app;
130 130
 				$children['onExecute'] = $drop_execute;
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 			else
135 135
 			{
136
-				foreach($children['children'] as $portlet => $app_portlet)
136
+				foreach ($children['children'] as $portlet => $app_portlet)
137 137
 				{
138
-					if(!is_array($app_portlet)) continue;
138
+					if (!is_array($app_portlet)) continue;
139 139
 					$app_portlet['class'] = $portlet;
140
-					$app_portlet['id'] = 'drop_' . $app_portlet['id'];
140
+					$app_portlet['id'] = 'drop_'.$app_portlet['id'];
141 141
 					$app_portlet['onExecute'] = $drop_execute;
142 142
 					$app_portlet['acceptedTypes'] = $app;
143 143
 					$app_portlet['type'] = 'drop';
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	{
162 162
 		$portlets = array();
163 163
 
164
-		foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context)
164
+		foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context)
165 165
 		{
166
-			if(strpos($id,'portlet_') !== 0 || // Not a portlet
166
+			if (strpos($id, 'portlet_') !== 0 || // Not a portlet
167 167
 				in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here
168 168
 				!is_array($context) // Not a valid portlet (probably user deleted a default)
169 169
 			) continue;
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 			$classname = $context['class'];
172 172
 
173 173
 			// Avoid portlets for apps user can't use (eg. from defaults/forced)
174
-			list($app,$other) = explode('_',$classname);
175
-			if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other;
176
-			if(!$GLOBALS['egw_info']['user']['apps'][$app]) {
174
+			list($app, $other) = explode('_', $classname);
175
+			if (!$GLOBALS['egw_info']['apps'][$app]) $app .= '_'.$other;
176
+			if (!$GLOBALS['egw_info']['user']['apps'][$app]) {
177 177
 				continue;
178 178
 			}
179 179
 
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			// Get settings
188 188
 			// Exclude common attributes changed through UI and settings lacking a type
189 189
 			$settings = $portlet->get_properties();
190
-			foreach($settings as $key => $setting)
190
+			foreach ($settings as $key => $setting)
191 191
 			{
192
-				if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
192
+				if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]);
193 193
 			}
194 194
 			$settings += $context;
195
-			foreach(home_portlet::$common_attributes as $attr)
195
+			foreach (home_portlet::$common_attributes as $attr)
196 196
 			{
197 197
 				unset($settings[$attr]);
198 198
 			}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 			// Add in default for admins
206 206
 			self::create_default_actions($actions, $id);
207 207
 
208
-			$template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions);
208
+			$template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions);
209 209
 
210 210
 			$portlets[] = $portlet_content;
211 211
 		}
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false)
231 231
 	{
232
-		if(!$context['class']) $context['class'] = 'home_link_portlet';
232
+		if (!$context['class']) $context['class'] = 'home_link_portlet';
233 233
 
234 234
 		// This should be set already, but just in case the execution path
235 235
 		// is different from normal...
236
-		if(Api\Json\Response::isJSONResponse())
236
+		if (Api\Json\Response::isJSONResponse())
237 237
 		{
238 238
 			$GLOBALS['egw']->framework->response = Api\Json\Response::get();
239 239
 		}
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 
249 249
 		// Exclude common attributes changed through UI and settings lacking a type
250 250
 		$settings = $portlet->get_properties();
251
-		foreach($settings as $key => $setting)
251
+		foreach ($settings as $key => $setting)
252 252
 		{
253
-			if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
253
+			if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]);
254 254
 		}
255 255
 		$settings += $context;
256
-		foreach(home_portlet::$common_attributes as $attr)
256
+		foreach (home_portlet::$common_attributes as $attr)
257 257
 		{
258 258
 			unset($settings[$attr]);
259 259
 		}
@@ -268,31 +268,31 @@  discard block
 block discarded – undo
268 268
 		self::create_default_actions($attributes['actions'], $id);
269 269
 
270 270
 		// Set any provided common attributes (size, etc)
271
-		foreach(home_portlet::$common_attributes as $name)
271
+		foreach (home_portlet::$common_attributes as $name)
272 272
 		{
273
-			if(array_key_exists($name, $context))
273
+			if (array_key_exists($name, $context))
274 274
 			{
275 275
 				$attributes[$name] = $context[$name];
276 276
 			}
277 277
 		}
278
-		foreach($attributes as $attr => $value)
278
+		foreach ($attributes as $attr => $value)
279 279
 		{
280 280
 			$etemplate->setElementAttribute($id, $attr, $value);
281 281
 		}
282 282
 
283 283
 		// Make sure custom javascript is loaded
284 284
 		$appname = $context['appname'];
285
-		if(!$appname)
285
+		if (!$appname)
286 286
 		{
287
-			list($app) = explode('_',$classname);
288
-			if($GLOBALS['egw_info']['apps'][$app])
287
+			list($app) = explode('_', $classname);
288
+			if ($GLOBALS['egw_info']['apps'][$app])
289 289
 			{
290 290
 				$appname = $app;
291 291
 			}
292 292
 		}
293 293
 		Framework::includeJS('', $classname, $appname ? $appname : 'home');
294 294
 
295
-		if($full_exec)
295
+		if ($full_exec)
296 296
 		{
297 297
 			$content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1);
298 298
 		}
@@ -309,23 +309,23 @@  discard block
 block discarded – undo
309 309
 	protected function get_legacy_portlets(&$content, &$attributes)
310 310
 	{
311 311
 		$sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']);
312
-		$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display');
312
+		$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display');
313 313
 
314
-		foreach($sorted_apps as $appname)
314
+		foreach ($sorted_apps as $appname)
315 315
 		{
316 316
 			// If there's already [new] settings, or no preference, skip it
317
-			if($content[$appname]) continue;
317
+			if ($content[$appname]) continue;
318 318
 			$no_pref = true;
319
-			foreach($portal_oldvarnames as $varcheck)
319
+			foreach ($portal_oldvarnames as $varcheck)
320 320
 			{
321 321
 				$thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck];
322
-				if($thisd)
322
+				if ($thisd)
323 323
 				{
324 324
 					$no_pref = false;
325 325
 					break;
326 326
 				}
327 327
 			}
328
-			if($no_pref || !Api\Hooks::exists('home', $appname))
328
+			if ($no_pref || !Api\Hooks::exists('home', $appname))
329 329
 			{
330 330
 				continue;
331 331
 			}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 			$_content = '';
337 337
 			$_attributes = array();
338 338
 			$this->get_portlet($appname, $context, $_content, $_attributes);
339
-			if(trim($_content))
339
+			if (trim($_content))
340 340
 			{
341 341
 				$content[$appname] = $_content;
342 342
 				$attributes[$appname] = $_attributes;
@@ -355,24 +355,24 @@  discard block
 block discarded – undo
355 355
 
356 356
 			// Ignore some problem files and base classes that shouldn't be options
357 357
 			$ignore = array(
358
-				'.','..',
358
+				'.', '..',
359 359
 				'class.home_portlet.inc.php',
360 360
 				'class.home_legacy_portlet.inc.php',
361 361
 				'class.home_favorite_portlet.inc.php'
362 362
 			);
363 363
 			// Look through all known classes for portlets - for now, they need 'portlet' in the file name
364
-			foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
364
+			foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname)
365 365
 			{
366
-				if(in_array($appname, array('phpgwapi', 'felamimail'))) continue;
367
-				$files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/');
368
-				if(!$files) continue;
366
+				if (in_array($appname, array('phpgwapi', 'felamimail'))) continue;
367
+				$files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/');
368
+				if (!$files) continue;
369 369
 
370
-				foreach($files as $entry)
370
+				foreach ($files as $entry)
371 371
 				{
372
-					if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet'))
372
+					if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet'))
373 373
 					{
374 374
 						list(,$classname) = explode('.', $entry);
375
-						if(class_exists($classname) &&
375
+						if (class_exists($classname) &&
376 376
 							in_array('home_portlet', class_parents($classname, false)))
377 377
 						{
378 378
 							$classes[$appname][] = $classname;
@@ -384,19 +384,19 @@  discard block
 block discarded – undo
384 384
 					}
385 385
 				}
386 386
 
387
-				if(!$classes[$appname]) continue;
387
+				if (!$classes[$appname]) continue;
388 388
 
389 389
 				// Build 'Add' actions for each discovered portlet.
390 390
 				// Portlets from other apps go in sub-actions
391
-				$add_to =& $list;
392
-				if($classes[$appname] && $appname != 'home')
391
+				$add_to = & $list;
392
+				if ($classes[$appname] && $appname != 'home')
393 393
 				{
394 394
 					$list[$appname] = array(
395 395
 						'caption' => lang($appname),
396 396
 					);
397
-					$add_to =& $list[$appname]['children'];
397
+					$add_to = & $list[$appname]['children'];
398 398
 				}
399
-				foreach($classes[$appname] as $portlet)
399
+				foreach ($classes[$appname] as $portlet)
400 400
 				{
401 401
 					$instance = new $portlet();
402 402
 					$desc = $instance->get_description();
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
 		}, array(), 60);
417 417
 
418 418
 		// Filter list by current user's permissions
419
-		foreach(array_keys($list) as $appname)
419
+		foreach (array_keys($list) as $appname)
420 420
 		{
421
-			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
422
-				if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
421
+			if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
422
+				if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
423 423
 				{
424 424
 					unset($list[$appname]);
425 425
 				}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 */
437 437
 	protected static function create_default_actions(&$actions, $portlet_id = null)
438 438
 	{
439
-		if($GLOBALS['egw_info']['user']['apps']['admin'])
439
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
440 440
 		{
441 441
 			$actions['add_default'] = array(
442 442
 				'type'		=> 'popup',
@@ -446,25 +446,25 @@  discard block
 block discarded – undo
446 446
 				'icon'		=> 'preference'
447 447
 			);
448 448
 			// Customize for the given portlet
449
-			if($portlet_id !== null)
449
+			if ($portlet_id !== null)
450 450
 			{
451
-				foreach(array('forced','group','default') as $location)
451
+				foreach (array('forced', 'group', 'default') as $location)
452 452
 				{
453 453
 					$loc = $GLOBALS['egw']->preferences->$location;
454 454
 
455
-					if($loc['home'][$portlet_id])
455
+					if ($loc['home'][$portlet_id])
456 456
 					{
457 457
 						// If it's forced, no point in setting default
458
-						if($location == 'forced')
458
+						if ($location == 'forced')
459 459
 						{
460 460
 							unset($actions['add_default']);
461 461
 						}
462 462
 						// If it's a group, we'd like to know which
463
-						if($location == 'group')
463
+						if ($location == 'group')
464 464
 						{
465 465
 							$options = array('account_type' => 'groups');
466
-							$groups = Api\Accounts::link_query('',$options);
467
-							foreach(array_keys($groups) as $gid)
466
+							$groups = Api\Accounts::link_query('', $options);
467
+							foreach (array_keys($groups) as $gid)
468 468
 							{
469 469
 								$prefs = new Api\Preferences($gid);
470 470
 								$prefs->read_repository();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 						}
478 478
 						$actions['remove_default_'.$location] = array(
479 479
 							'type'		=> 'popup',
480
-							'caption'	=> lang('Remove as default for %1',is_numeric($location) ? Api\Accounts::id2name($location,'account_fullname') : $location),
480
+							'caption'	=> lang('Remove as default for %1', is_numeric($location) ? Api\Accounts::id2name($location, 'account_fullname') : $location),
481 481
 							'onExecute'	=> 'javaScript:app.home.set_default',
482 482
 							'group'		=> 'Admins',
483 483
 							'portlet_group' => $location
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 		}
489 489
 
490 490
 		// Change action for forced
491
-		if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id])
491
+		if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id])
492 492
 		{
493 493
 			// No one can remove it
494 494
 			$actions['remove_portlet']['enabled'] = false;
495
-			$actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')';
495
+			$actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')';
496 496
 
497 497
 			// Non-admins can't edit it
498
-			if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
498
+			if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
499 499
 			{
500 500
 				$actions['edit_settings']['enabled'] = false;
501 501
 				$actions['edit_settings']['visible'] = false;
@@ -514,14 +514,14 @@  discard block
 block discarded – undo
514 514
 	public function ajax_set_properties($portlet_id, $attributes, $values, $group = false)
515 515
 	{
516 516
 		//error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)");
517
-		if(!$attributes)
517
+		if (!$attributes)
518 518
 		{
519 519
 			$attributes = array();
520 520
 		}
521 521
 
522
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
522
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
523 523
 		{
524
-			if($group == 'forced')
524
+			if ($group == 'forced')
525 525
 			{
526 526
 				// Quietly reject
527 527
 				return;
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 			// Not an admin, can only override.
530 530
 			$group = false;
531 531
 		}
532
-		if($group && $GLOBALS['egw_info']['user']['apps']['admin'])
532
+		if ($group && $GLOBALS['egw_info']['user']['apps']['admin'])
533 533
 		{
534 534
 			$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
535 535
 		}
@@ -543,23 +543,23 @@  discard block
 block discarded – undo
543 543
 
544 544
 		$response = Api\Json\Response::get();
545 545
 
546
-		if($values =='~reload~')
546
+		if ($values == '~reload~')
547 547
 		{
548 548
 			$full_exec = true;
549 549
 			$values = array();
550 550
 		}
551
-		if($values == '~remove~')
551
+		if ($values == '~remove~')
552 552
 		{
553 553
 			// Already removed client side, needs to be removed permanently
554
-			$default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id];
554
+			$default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id];
555 555
 
556
-			if($default)
556
+			if ($default)
557 557
 			{
558 558
 				// Can't delete forced - not a UI option though
559
-				if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id])
559
+				if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id])
560 560
 				{
561 561
 					// Set a flag to override default instead of just delete
562
-					$GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted');
562
+					$GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted');
563 563
 					$GLOBALS['egw']->preferences->save_repository();
564 564
 				}
565 565
 			}
@@ -576,19 +576,19 @@  discard block
 block discarded – undo
576 576
 			// Remove some constant stuff that winds up here
577 577
 			unset($values['edit_template']);
578 578
 			unset($values['readonly']);
579
-			unset($values['disabled']);unset($values['no_lang']);
579
+			unset($values['disabled']); unset($values['no_lang']);
580 580
 			unset($values['actions']);
581 581
 			unset($values['statustext']);
582
-			unset($values['type']);unset($values['label']);unset($values['status']);
583
-			unset($values['value']);unset($values['align']);
582
+			unset($values['type']); unset($values['label']); unset($values['status']);
583
+			unset($values['value']); unset($values['align']);
584 584
 
585 585
 			// Get portlet settings, and merge new with old
586 586
 			$context = array_merge((array)$portlets[$portlet_id], $values);
587 587
 			$context['group'] = $group;
588 588
 
589 589
 			// Handle add IDs
590
-			$classname =& $context['class'];
591
-			if(strpos($classname,'add_') == 0 && !class_exists($classname))
590
+			$classname = & $context['class'];
591
+			if (strpos($classname, 'add_') == 0 && !class_exists($classname))
592 592
 			{
593 593
 				$add = true;
594 594
 				$classname = substr($classname, 4);
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
 			$portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec);
598 598
 
599 599
 			$context['class'] = get_class($portlet);
600
-			foreach($portlet->get_properties() as $property)
600
+			foreach ($portlet->get_properties() as $property)
601 601
 			{
602
-				if($values[$property['name']])
602
+				if ($values[$property['name']])
603 603
 				{
604 604
 					$context[$property['name']] = $values[$property['name']];
605 605
 				}
606
-				elseif($portlets[$portlet_id][$property['name']])
606
+				elseif ($portlets[$portlet_id][$property['name']])
607 607
 				{
608 608
 					$context[$property['name']] = $portlets[$portlet_id][$property['name']];
609 609
 				}
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 			$update = array('attributes' => $attributes);
614 614
 
615 615
 			// New portlet?  Flag going straight to edit mode
616
-			if($add)
616
+			if ($add)
617 617
 			{
618 618
 				$update['edit_settings'] = true;
619 619
 			}
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 		}
626 626
 
627 627
 		// Save updated preferences
628
-		$prefs->save_repository(True,$type);
628
+		$prefs->save_repository(True, $type);
629 629
 	}
630 630
 
631 631
 	/**
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 	public static function ajax_set_default($action, $portlet_ids, $group)
639 639
 	{
640 640
 		// Admins only
641
-		if(!$GLOBALS['egw_info']['apps']['admin']) return;
641
+		if (!$GLOBALS['egw_info']['apps']['admin']) return;
642 642
 
643 643
 		// Load the appropriate group
644
-		if($group)
644
+		if ($group)
645 645
 		{
646 646
 			$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
647 647
 		}
@@ -653,30 +653,30 @@  discard block
 block discarded – undo
653 653
 
654 654
 		$type = is_numeric($group) ? "user" : $group;
655 655
 
656
-		if($action == 'add')
656
+		if ($action == 'add')
657 657
 		{
658
-			foreach($portlet_ids as $id)
658
+			foreach ($portlet_ids as $id)
659 659
 			{
660 660
 				Api\Json\Response::get()->call('egw.message', lang("Set default"));
661 661
 				// Current user is setting the default, copy their settings
662 662
 				$settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id];
663 663
 				$settings['group'] = $group;
664
-				$prefs->add('home',$id,$settings,$type);
664
+				$prefs->add('home', $id, $settings, $type);
665 665
 
666 666
 				// Remove user's copy
667
-				$GLOBALS['egw']->preferences->delete('home',$id);
667
+				$GLOBALS['egw']->preferences->delete('home', $id);
668 668
 				$GLOBALS['egw']->preferences->save_repository(true);
669 669
 			}
670 670
 		}
671 671
 		else if ($action == "delete")
672 672
 		{
673
-			foreach($portlet_ids as $id)
673
+			foreach ($portlet_ids as $id)
674 674
 			{
675 675
 				Api\Json\Response::get()->call('egw.message', lang("Removed default"));
676
-				$prefs->delete('home',$id, $type);
676
+				$prefs->delete('home', $id, $type);
677 677
 			}
678 678
 		}
679
-		$prefs->save_repository(false,$type);
679
+		$prefs->save_repository(false, $type);
680 680
 
681 681
 		// Update Api\Preferences client side for consistency
682 682
 		$prefs = $GLOBALS['egw']->preferences;
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 						'state' => array(
730 730
 							'cat_id' => '0',
731 731
 							'filter' => 'default',
732
-							'owner' => 0,	// current user
732
+							'owner' => 0, // current user
733 733
 							'sortby' => 'user',
734 734
 							'planner_days' => '0',
735 735
 							'view' => 'week',
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 		{
779 779
 			unset($app_prefs['home']['portlet_setup142n']);
780 780
 		}
781
-		foreach($app_prefs as $app => $prefs)
781
+		foreach ($app_prefs as $app => $prefs)
782 782
 		{
783
-			foreach($prefs as $name => $value)
783
+			foreach ($prefs as $name => $value)
784 784
 			{
785 785
 				Api\Preferences::delete_preference($app, $name, 'default');
786 786
 				$preferences->add($app, $name, $value, 'default');
@@ -801,10 +801,10 @@  discard block
 block discarded – undo
801 801
 	 */
802 802
 	public static function setup_default_home()
803 803
 	{
804
-		switch($GLOBALS['egw_info']['server'][self::HOME_VERSION])
804
+		switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION])
805 805
 		{
806 806
 			case self::CURRENT_HOME_VERSION:
807
-				return;	// already up to date --> nothing to do
807
+				return; // already up to date --> nothing to do
808 808
 
809 809
 			default:
810 810
 				call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION)));
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.
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   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  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
 	protected static $plugin_options = array(
24
-		'fieldsep', 		// char
25
-		'charset', 			// string
26
-		'record_owner', 	// int
27
-		'update_cats', 			// string {override|add} overides record
24
+		'fieldsep', // char
25
+		'charset', // string
26
+		'record_owner', // int
27
+		'update_cats', // string {override|add} overides record
28 28
 								// with cat(s) from csv OR add the cat from
29 29
 								// csv file to exeisting cat(s) of record
30 30
 		'num_header_lines', // int number of header lines
31 31
 		'field_conversion', // array( $csv_col_num => conversion)
32
-		'field_mapping',	// array( $csv_col_num => adb_filed)
33
-		'conditions',		/* => array containing condition arrays:
32
+		'field_mapping', // array( $csv_col_num => adb_filed)
33
+		'conditions', /* => array containing condition arrays:
34 34
 				'type' => exists, // exists
35 35
 				'string' => '#kundennummer',
36 36
 				'true' => array(
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * Actions wich could be done to data entries
49 49
 	 * If your plugin supports different actions, be sure to modify this array
50 50
 	 */
51
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
51
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
52 52
 
53 53
 	/**
54 54
 	 * Conditions for actions
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @var array
58 58
 	 */
59
-	protected static $conditions = array( 'exists', 'equal', 'less_than');
59
+	protected static $conditions = array('exists', 'equal', 'less_than');
60 60
 
61 61
 	/**
62 62
 	 * This is the definition that will be used to deal with the CSV file
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @param string $_charset
122 122
 	 * @param definition $_definition
123 123
 	 */
124
-	public function import( $_stream, importexport_definition $_definition ) {
125
-		$import_csv = new importexport_import_csv( $_stream, array(
124
+	public function import($_stream, importexport_definition $_definition) {
125
+		$import_csv = new importexport_import_csv($_stream, array(
126 126
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
127 127
 			'charset' => $_definition->plugin_options['charset'],
128 128
 		));
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 		$this->definition = $_definition;
131 131
 
132 132
 		// user, is admin ?
133
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
133
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
134 134
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
135 135
 
136 136
 		// dry run?
137
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
137
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
138 138
 
139 139
 		// set FieldMapping.
140 140
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
144 144
 
145 145
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
146
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
147 147
 			$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']) {
148
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
149 149
 			// First method is preferred
150 150
 			$import_csv->skip_records(1);
151 151
 		}
@@ -167,38 +167,38 @@  discard block
 block discarded – undo
167 167
 
168 168
 		$this->init($_definition);
169 169
 
170
-		while ( $record = $import_csv->get_record() ) {
170
+		while ($record = $import_csv->get_record()) {
171 171
 			$success = false;
172 172
 
173 173
 			// don't import empty records
174
-			if( count( array_unique( $record ) ) < 2 ) continue;
174
+			if (count(array_unique($record)) < 2) continue;
175 175
 
176 176
 
177 177
 			$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;
178
+				if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
179 179
 
180 180
 			$egw_record = new $record_class();
181 181
 			$egw_record->set_record($record);
182 182
 			$success = $this->import_record($egw_record, $import_csv);
183 183
 
184
-			if($success)
184
+			if ($success)
185 185
 			{
186 186
 				$this->do_special_fields($egw_record, $import_csv);
187 187
 			}
188
-			if($success) $count++;
188
+			if ($success) $count++;
189 189
 
190 190
 			// Add some more time
191
-			if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
191
+			if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
192 192
 			{
193 193
 				set_time_limit(10);
194 194
 			}
195 195
 
196 196
 			// Keep a few records for preview, but process the whole file
197
-			if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
197
+			if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
198 198
 			{
199 199
 				$this->preview_records[] = $egw_record;
200 200
 			}
201
-			if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
201
+			if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
202 202
 			{
203 203
 				$this->errors[] = 'Too many errors, aborted';
204 204
 				break;
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 	*/
227 227
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 228
 	{
229
-		if ( $this->definition->plugin_options['conditions'] ) {
230
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
229
+		if ($this->definition->plugin_options['conditions']) {
230
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
231 231
 				$result = false;
232
-				switch ( $condition['type'] ) {
232
+				switch ($condition['type']) {
233 233
 					// exists
234 234
 					case 'exists' :
235 235
 						// Check for that record
@@ -244,23 +244,23 @@  discard block
 block discarded – undo
244 244
 					default :
245 245
 						die('condition / action not supported!!!');
246 246
 				}
247
-				if($result)
247
+				if ($result)
248 248
 				{
249 249
 					// Apply true action to any matching records found
250 250
 					$action = $condition['true'];
251
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
251
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
252 252
 				}
253 253
 				else
254 254
 				{
255 255
 					// Apply false action if no matching records found
256 256
 					$action = $condition['false'];
257
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
257
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
258 258
 				}
259 259
 				if ($action['stop']) break;
260 260
 			}
261 261
 		} else {
262 262
 			// unconditional insert
263
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
263
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
264 264
 		}
265 265
 
266 266
 		return $success;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 * @param int $record_num Which record number is being dealt with.  Used for error messages.
322 322
 	 * @return bool success or not
323 323
 	 */
324
-	protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 );
324
+	protected abstract function action($_action, importexport_iface_egw_record &$record, $record_num = 0);
325 325
 
326 326
 	/**
327 327
 	 * Handle special fields
@@ -336,47 +336,47 @@  discard block
 block discarded – undo
336 336
 		$id = $record->get_identifier();
337 337
 
338 338
 
339
-		foreach(self::$special_fields as $field => $desc) {
340
-			if(!$record->$field) continue;
339
+		foreach (self::$special_fields as $field => $desc) {
340
+			if (!$record->$field) continue;
341 341
 
342 342
 			// Warn if there's no ID unless it's a dry_run because there probably won't be an ID then
343
-			if(!$this->dry_run && !$id)
343
+			if (!$this->dry_run && !$id)
344 344
 			{
345 345
 				$this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record";
346 346
 				return;
347 347
 			}
348
-			if(strpos($field, 'link') === 0) {
349
-				list($app, $app_id) = explode(':', $record->$field,2);
348
+			if (strpos($field, 'link') === 0) {
349
+				list($app, $app_id) = explode(':', $record->$field, 2);
350 350
 
351
-				list($link, $type) = explode('_',$field);
351
+				list($link, $type) = explode('_', $field);
352 352
 
353 353
 				// Searching, take first result
354
-				if($type == 'custom')
354
+				if ($type == 'custom')
355 355
 				{
356 356
 					$app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position());
357 357
 				}
358
-				else if($type == 'search')
358
+				else if ($type == 'search')
359 359
 				{
360 360
 					$result = Link::query($app, $app_id);
361 361
 					do
362 362
 					{
363 363
 						$app_id = key($result);
364 364
 						shift($result);
365
-					} while($result && !$app_id);
365
+					} while ($result && !$app_id);
366 366
 				}
367 367
 			} else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) {
368 368
 				$app = $field;
369 369
 				$app_id = $record->$field;
370 370
 
371 371
 				// Searching, take first result
372
-				if(!is_numeric($app_id))
372
+				if (!is_numeric($app_id))
373 373
 				{
374 374
 					$result = Link::query($app, $app_id);
375 375
 					do
376 376
 					{
377 377
 						$app_id = key($result);
378 378
 						shift($result);
379
-					} while($result && !$app_id);
379
+					} while ($result && !$app_id);
380 380
 				}
381 381
 			}
382 382
 			else if ($field == 'contact')
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			}
388 388
 			if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id))
389 389
 			{
390
-				$link_id = Link::link($this->definition->application,$id,$app,$app_id);
390
+				$link_id = Link::link($this->definition->application, $id, $app, $app_id);
391 391
 			}
392 392
 		}
393 393
 	}
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
 	 * @param importexport_definition $definition
405 405
 	 * @return String HTML for preview
406 406
          */
407
-	public function preview( $stream, importexport_definition $definition )
407
+	public function preview($stream, importexport_definition $definition)
408 408
 	{
409 409
 		$this->import($stream, $definition);
410 410
 		rewind($stream);
411 411
 
412 412
 		// Set up result
413
-		$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
413
+		$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
414 414
 
415 415
 		// Load labels for app
416 416
 		$record_class = get_class($this->preview_records[0]);
@@ -419,27 +419,27 @@  discard block
 block discarded – undo
419 419
 		$labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']);
420 420
 
421 421
 		$plugin = get_called_class();
422
-		$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
422
+		$wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin);
423 423
 		try {
424 424
 			$wizard = new $wizard_name;
425 425
 			$fields = $wizard->get_import_fields();
426
-			foreach($labels as $field => &$label)
426
+			foreach ($labels as $field => &$label)
427 427
 			{
428
-				if($fields[$field]) $label = $fields[$field];
428
+				if ($fields[$field]) $label = $fields[$field];
429 429
 			}
430 430
 		} catch (Exception $e) {
431 431
 			Api\Translation::add_app($definition->application);
432
-			foreach($labels as $field => &$label) {
432
+			foreach ($labels as $field => &$label) {
433 433
 				$label = lang($label);
434 434
 			}
435 435
 		}
436 436
 
437 437
 		// Set up HTML
438 438
 		$rows['h1'] = $labels;
439
-		foreach($this->preview_records as $i => $row_data)
439
+		foreach ($this->preview_records as $i => $row_data)
440 440
 		{
441 441
 			// Convert to human-friendly
442
-			importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups);
442
+			importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups);
443 443
 			$this->row_preview($row_data);
444 444
 			$rows[] = $row_data->get_record_array();
445 445
 		}
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @param string $org_name
469 469
 	 * @return int|boolean Contact ID of first match, or false if none found
470 470
 	 */
471
-	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) {
471
+	public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) {
472 472
 
473 473
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
474 474
 		static $contacts;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
479 479
 		}
480 480
 		$n_family = trim($n_family);
481
-		if(!is_null($n_given)) $n_given = trim($n_given);
481
+		if (!is_null($n_given)) $n_given = trim($n_given);
482 482
 		if (!is_object($contacts))
483 483
 		{
484 484
 			$contacts = new Api\Contacts();
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 		if (!is_null($org_name))	// org_name given?
487 487
 		{
488 488
 			$org_name = trim($org_name);
489
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
489
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
490 490
 			if (!count($addrs))
491 491
 			{
492
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
492
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
493 493
 			}
494 494
 		}
495 495
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 		}
499 499
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
500 500
 		{
501
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
501
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
502 502
 		}
503 503
 		if (count($addrs))
504 504
 		{
505
-			if(!$record || !$record->get_identifier())
505
+			if (!$record || !$record->get_identifier())
506 506
 			{
507 507
 				return $addrs[0]['id'];
508 508
 			}
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 				{
513 513
 					$id = key($addrs);
514 514
 					array_shift($addrs);
515
-				} while($addrs && !$id && $id == $record->get_identifier());
515
+				} while ($addrs && !$id && $id == $record->get_identifier());
516 516
 				return $id;
517 517
 			}
518 518
 		}
@@ -527,22 +527,22 @@  discard block
 block discarded – undo
527 527
 	 * @param string $app Target application name
528 528
 	 * @param string $value CSV value in the form of custom_field_name:value
529 529
 	 */
530
-	protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num)
530
+	protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value, $record_num)
531 531
 	{
532 532
 		$app_id = false;
533 533
 
534
-		list($custom_field, $value) = explode(':',$value);
534
+		list($custom_field, $value) = explode(':', $value);
535 535
 		// Find matching entry
536
-		if($app && $custom_field && $value)
536
+		if ($app && $custom_field && $value)
537 537
 		{
538 538
 			$cfs = Api\Storage\Customfields::get($app);
539 539
 			// Error if no custom fields, probably something wrong in definition
540
-			if(!$cfs[$custom_field])
540
+			if (!$cfs[$custom_field])
541 541
 			{
542 542
 				// Check for users specifing label instead of name
543
-				foreach($cfs as $name => $settings)
543
+				foreach ($cfs as $name => $settings)
544 544
 				{
545
-					if(strtolower($settings['label']) == strtolower($custom_field))
545
+					if (strtolower($settings['label']) == strtolower($custom_field))
546 546
 					{
547 547
 						$custom_field = $name;
548 548
 						break;
@@ -551,30 +551,30 @@  discard block
 block discarded – undo
551 551
 			}
552 552
 
553 553
 			// Couldn't find field, give an error - something's wrong
554
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
554
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
555 555
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
556 556
 					$custom_field, lang($app));
557 557
 				return false;
558 558
 			}
559
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
559
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
560 560
 error_log("Searching for $custom_field = $value");
561 561
 			// Search
562
-			if(Link::get_registry($app, 'query'))
562
+			if (Link::get_registry($app, 'query'))
563 563
 			{
564
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
564
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
565 565
 				$result = Link::query($app, '', $options);
566 566
 
567 567
 				// Only one allowed
568
-				if($record->get_identifier())
568
+				if ($record->get_identifier())
569 569
 				{
570
-					while(key($result) == $record->get_identifier())
570
+					while (key($result) == $record->get_identifier())
571 571
 					{
572 572
 						array_shift($result);
573 573
 					}
574 574
 				}
575
-				if(count($result) != 1)
575
+				if (count($result) != 1)
576 576
 				{
577
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
577
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
578 578
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
579 579
 						$custom_field, count($result), lang($app), $options['filter'][0]
580 580
 					);
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	 * 		preserv		=> array,
626 626
 	 * )
627 627
 	 */
628
-	public function get_options_etpl(importexport_definition &$definition=null)
628
+	public function get_options_etpl(importexport_definition &$definition = null)
629 629
 	{
630 630
 		// lets do it!
631 631
 	}
Please login to merge, or discard this patch.
Braces   +94 added lines, -35 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
@@ -256,9 +274,14 @@  discard block
 block discarded – undo
256 274
 					$action = $condition['false'];
257 275
 					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
258 276
 				}
259
-				if ($action['stop']) break;
277
+				if ($action['stop'])
278
+				{
279
+					break;
280
+				}
260 281
 			}
261
-		} else {
282
+		}
283
+		else
284
+		{
262 285
 			// unconditional insert
263 286
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
264 287
 		}
@@ -336,8 +359,12 @@  discard block
 block discarded – undo
336 359
 		$id = $record->get_identifier();
337 360
 
338 361
 
339
-		foreach(self::$special_fields as $field => $desc) {
340
-			if(!$record->$field) continue;
362
+		foreach(self::$special_fields as $field => $desc)
363
+		{
364
+			if(!$record->$field)
365
+			{
366
+				continue;
367
+			}
341 368
 
342 369
 			// Warn if there's no ID unless it's a dry_run because there probably won't be an ID then
343 370
 			if(!$this->dry_run && !$id)
@@ -345,7 +372,8 @@  discard block
 block discarded – undo
345 372
 				$this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record";
346 373
 				return;
347 374
 			}
348
-			if(strpos($field, 'link') === 0) {
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
 
@@ -635,7 +690,8 @@  discard block
 block discarded – undo
635 690
 	 *
636 691
 	 * @return string etemplate name
637 692
 	 */
638
-	public function get_selectors_etpl() {
693
+	public function get_selectors_etpl()
694
+	{
639 695
 		// lets do it!
640 696
 	}
641 697
 
@@ -647,7 +703,8 @@  discard block
 block discarded – undo
647 703
 	*       record_# => warning message
648 704
 	*       )
649 705
 	*/
650
-	public function get_warnings() {
706
+	public function get_warnings()
707
+	{
651 708
 		return $this->warnings;
652 709
 	}
653 710
 
@@ -659,7 +716,8 @@  discard block
 block discarded – undo
659 716
 	*       record_# => error message
660 717
 	*       )
661 718
 	*/
662
-	public function get_errors() {
719
+	public function get_errors()
720
+	{
663 721
 		return $this->errors;
664 722
 	}
665 723
 
@@ -671,7 +729,8 @@  discard block
 block discarded – undo
671 729
 	*       action => record count
672 730
 	* )
673 731
 	*/
674
-	public function get_results() {
732
+	public function get_results()
733
+	{
675 734
 			return $this->results;
676 735
 	}
677 736
 } // end of iface_export_plugin
Please login to merge, or discard this patch.