@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | </columns> |
57 | 57 | <rows> |
58 | 58 | '; |
59 | -foreach($trs[2] as $n => $tr) |
|
59 | +foreach ($trs[2] as $n => $tr) |
|
60 | 60 | { |
61 | 61 | if (strpos($tr, '{title}') || strpos($tr, '<input type="submit"')) continue; |
62 | 62 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | { |
65 | 65 | die("No td tags found in $n. tr: $tr"); |
66 | 66 | } |
67 | - if (($commented = !empty($trs[1][$n])? $trs[1][$n] : '')) |
|
67 | + if (($commented = !empty($trs[1][$n]) ? $trs[1][$n] : '')) |
|
68 | 68 | { |
69 | 69 | echo "\t\t\t\t$commented\n"; |
70 | 70 | } |
71 | 71 | echo "\t\t\t\t<row>\n"; |
72 | - foreach($tds[2] as $t => $td) |
|
72 | + foreach ($tds[2] as $t => $td) |
|
73 | 73 | { |
74 | 74 | if (preg_match('|^\s*<([^ >]+)\s*([^/>]+)/?>(.*)\s*$|sui', $td, $matches)) |
75 | 75 | { |
76 | 76 | $attrs = preg_match_all('|\s*([^=]+)="([^"]+)"|', $matches[2], $attrs) ? |
77 | 77 | array_combine($attrs[1], $attrs[2]) : array(); |
78 | 78 | |
79 | - switch($matches[1]) |
|
79 | + switch ($matches[1]) |
|
80 | 80 | { |
81 | 81 | case 'input': |
82 | 82 | case 'textarea': |
83 | 83 | echo "\t\t\t\t\t<textbox id=\"".$attrs['name'].'"'; |
84 | 84 | unset($attrs['value'], $attrs['name']); |
85 | - foreach($attrs as $name => $value) |
|
85 | + foreach ($attrs as $name => $value) |
|
86 | 86 | { |
87 | 87 | if ($name == 'type' && $value == 'password') $value = 'passwd'; |
88 | 88 | echo " $name=\"$value\""; |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | case 'select': |
104 | 104 | echo "\t\t\t\t\t<select id=\"".$attrs['name'].'"'; |
105 | 105 | unset($attrs['name']); |
106 | - foreach($attrs as $name => $value) |
|
106 | + foreach ($attrs as $name => $value) |
|
107 | 107 | { |
108 | 108 | echo " $name=\"$value\""; |
109 | 109 | } |
110 | 110 | echo ">\n"; |
111 | 111 | if (preg_match_all('|<option\s+value="([^"]*)"\s*({selected_[^}]+})?>(.*)</option>|Usui', $matches[3], $options)) |
112 | 112 | { |
113 | - foreach($options[3] as $i => $label) |
|
113 | + foreach ($options[3] as $i => $label) |
|
114 | 114 | { |
115 | 115 | $label = preg_replace_callback('/{lang_([^}]+)}/', function($matches) |
116 | 116 | { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | echo "/>\n"; |
154 | 154 | if (!$commented && !empty($matches[3]) && trim($matches[3])) echo "\t\t\t\t\t<!-- ".trim($matches[3])." -->\n"; |
155 | 155 | } |
156 | - elseif(!$commented) |
|
156 | + elseif (!$commented) |
|
157 | 157 | { |
158 | 158 | echo "\t\t\t\t\t<!-- ".trim($td)." -->\n"; |
159 | 159 | } |
@@ -58,7 +58,10 @@ discard block |
||
58 | 58 | '; |
59 | 59 | foreach($trs[2] as $n => $tr) |
60 | 60 | { |
61 | - if (strpos($tr, '{title}') || strpos($tr, '<input type="submit"')) continue; |
|
61 | + if (strpos($tr, '{title}') || strpos($tr, '<input type="submit"')) |
|
62 | + { |
|
63 | + continue; |
|
64 | + } |
|
62 | 65 | |
63 | 66 | if (!preg_match_all('|<td\s*([^>]*)>(.*)</td>|Usui', $tr, $tds, PREG_PATTERN_ORDER)) |
64 | 67 | { |
@@ -84,7 +87,10 @@ discard block |
||
84 | 87 | unset($attrs['value'], $attrs['name']); |
85 | 88 | foreach($attrs as $name => $value) |
86 | 89 | { |
87 | - if ($name == 'type' && $value == 'password') $value = 'passwd'; |
|
90 | + if ($name == 'type' && $value == 'password') |
|
91 | + { |
|
92 | + $value = 'passwd'; |
|
93 | + } |
|
88 | 94 | echo " $name=\"$value\""; |
89 | 95 | } |
90 | 96 | echo "/>\n"; |
@@ -139,7 +145,10 @@ discard block |
||
139 | 145 | elseif (preg_match('/^\s*([^{]*){lang_([^}]+)}\s*(.*)$/sui', |
140 | 146 | str_replace(array(' ', '<b>', '</b>'), '', $td), $matches)) |
141 | 147 | { |
142 | - if (!$commented && trim($matches[1])) echo "\t\t\t\t\t<!-- $matches[1] -->\n"; |
|
148 | + if (!$commented && trim($matches[1])) |
|
149 | + { |
|
150 | + echo "\t\t\t\t\t<!-- $matches[1] -->\n"; |
|
151 | + } |
|
143 | 152 | echo "\t\t\t\t\t<description value=\"".htmlspecialchars(str_replace('_', ' ', $matches[2])).'"'; |
144 | 153 | if (trim($matches[3]) == ':') |
145 | 154 | { |
@@ -151,7 +160,10 @@ discard block |
||
151 | 160 | echo ' span="all" class="subHeader"'; |
152 | 161 | } |
153 | 162 | echo "/>\n"; |
154 | - if (!$commented && !empty($matches[3]) && trim($matches[3])) echo "\t\t\t\t\t<!-- ".trim($matches[3])." -->\n"; |
|
163 | + if (!$commented && !empty($matches[3]) && trim($matches[3])) |
|
164 | + { |
|
165 | + echo "\t\t\t\t\t<!-- ".trim($matches[3])." -->\n"; |
|
166 | + } |
|
155 | 167 | } |
156 | 168 | elseif(!$commented) |
157 | 169 | { |
@@ -2,7 +2,7 @@ |
||
2 | 2 | // dummy setup file |
3 | 3 | if (strpos($_SERVER['PHP_SELF'],'/setup/') === false) |
4 | 4 | { |
5 | - header('Location: /egroupware/setup/'); |
|
6 | - exit; |
|
5 | + header('Location: /egroupware/setup/'); |
|
6 | + exit; |
|
7 | 7 | } |
8 | 8 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | // dummy setup file |
3 | -if (strpos($_SERVER['PHP_SELF'],'/setup/') === false) |
|
3 | +if (strpos($_SERVER['PHP_SELF'], '/setup/') === false) |
|
4 | 4 | { |
5 | 5 | header('Location: /egroupware/setup/'); |
6 | 6 | exit; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @version $Id: class.accounts.inc.php 22048 2006-07-08 21:41:42Z ralfbecker $ |
22 | 22 | */ |
23 | 23 | |
24 | -if ($argc <= 1 || in_array($argv[1],array('-v','--help')) || $argv[1] == '--accounts-dn' && $argc <= 3|| |
|
25 | - !is_readable($file = $argv[$argc-1])) |
|
24 | +if ($argc <= 1 || in_array($argv[1], array('-v', '--help')) || $argv[1] == '--accounts-dn' && $argc <= 3 || |
|
25 | + !is_readable($file = $argv[$argc - 1])) |
|
26 | 26 | { |
27 | 27 | if ($file) |
28 | 28 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | $lines = file($file); |
35 | -foreach($lines as $l => $line) |
|
35 | +foreach ($lines as $l => $line) |
|
36 | 36 | { |
37 | 37 | $lines[$l] = rtrim($line); |
38 | 38 | } |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | { |
43 | 43 | $group2account = $argv[2]; |
44 | 44 | } |
45 | -$parts = explode('/',$group2account); |
|
45 | +$parts = explode('/', $group2account); |
|
46 | 46 | if (count($parts) != 4) |
47 | 47 | { |
48 | 48 | die("Wrong format for --group2accounts-dn, use something like '/cn=[^,]+,ou=groups/ou=accounts/'\n"); |
49 | 49 | } |
50 | 50 | $replace_with = $parts[2]; unset($parts[2]); |
51 | -$replace = implode('/',$parts); |
|
51 | +$replace = implode('/', $parts); |
|
52 | 52 | |
53 | 53 | $block = array(); |
54 | 54 | $i = 0; |
55 | -$lines[] = ''; // extra empty line, if none is behind the last block |
|
56 | -foreach($lines as $l => $line) |
|
55 | +$lines[] = ''; // extra empty line, if none is behind the last block |
|
56 | +foreach ($lines as $l => $line) |
|
57 | 57 | { |
58 | 58 | if ($line) |
59 | 59 | { |
60 | - @list($attr,$value) = explode(': ',$line,2); |
|
61 | - switch($attr) |
|
60 | + @list($attr, $value) = explode(': ', $line, 2); |
|
61 | + switch ($attr) |
|
62 | 62 | { |
63 | 63 | case 'dn': |
64 | 64 | $dn = $value; |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | $structural = $value; |
71 | 71 | break; |
72 | 72 | case 'memberUid': |
73 | - $member_dn = 'uid='.$value.','.preg_replace($replace,$replace_with,$dn); |
|
74 | - if (!in_array('dn: '.$member_dn,$lines)) continue; // member does not exist --> ignore him! |
|
73 | + $member_dn = 'uid='.$value.','.preg_replace($replace, $replace_with, $dn); |
|
74 | + if (!in_array('dn: '.$member_dn, $lines)) continue; // member does not exist --> ignore him! |
|
75 | 75 | $members[] = 'member: '.$member_dn; |
76 | 76 | // fall-through |
77 | 77 | default: |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | if (!$block) continue; |
85 | 85 | |
86 | 86 | // got a complete block |
87 | - if (in_array('posixGroup',$objectclasses)) |
|
87 | + if (in_array('posixGroup', $objectclasses)) |
|
88 | 88 | { |
89 | - switch($structural) |
|
89 | + switch ($structural) |
|
90 | 90 | { |
91 | 91 | case 'namedObject': // regular SuSE |
92 | - unset($objectclasses[array_search('namedObject',$objectclasses)]); |
|
92 | + unset($objectclasses[array_search('namedObject', $objectclasses)]); |
|
93 | 93 | // fall-through |
94 | 94 | case 'posixGroup': // nis |
95 | 95 | $objectclasses[] = $structural = 'groupOfNames'; |
96 | - if (!$members) $members[] = 'member: '.$dn; // member is a required attribute! |
|
97 | - $data = array_merge($members,$data); |
|
96 | + if (!$members) $members[] = 'member: '.$dn; // member is a required attribute! |
|
97 | + $data = array_merge($members, $data); |
|
98 | 98 | break; |
99 | 99 | case 'groupOfNames': // ok, already what we want |
100 | 100 | break; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | die("\nposixGroup dn: $dn has as structrualObjectClass $structural, not posixGroup, namedObject or groupOfNames!\n"); |
103 | 103 | } |
104 | 104 | $block = array('dn: '.$dn,); |
105 | - foreach($objectclasses as $class) |
|
105 | + foreach ($objectclasses as $class) |
|
106 | 106 | { |
107 | 107 | $block[] = 'objectClass: '.$class; |
108 | 108 | } |
109 | 109 | $block[] = 'structuralObjectClass: '.$class; |
110 | - $block = array_merge($block,$data); |
|
110 | + $block = array_merge($block, $data); |
|
111 | 111 | } |
112 | - echo implode("\n",$block)."\n\n"; |
|
112 | + echo implode("\n", $block)."\n\n"; |
|
113 | 113 | |
114 | 114 | // process next block |
115 | 115 | $block = $objectclasses = $members = $data = array(); |
@@ -71,7 +71,11 @@ discard block |
||
71 | 71 | break; |
72 | 72 | case 'memberUid': |
73 | 73 | $member_dn = 'uid='.$value.','.preg_replace($replace,$replace_with,$dn); |
74 | - if (!in_array('dn: '.$member_dn,$lines)) continue; // member does not exist --> ignore him! |
|
74 | + if (!in_array('dn: '.$member_dn,$lines)) |
|
75 | + { |
|
76 | + continue; |
|
77 | + } |
|
78 | + // member does not exist --> ignore him! |
|
75 | 79 | $members[] = 'member: '.$member_dn; |
76 | 80 | // fall-through |
77 | 81 | default: |
@@ -81,7 +85,10 @@ discard block |
||
81 | 85 | $block[] = $line; |
82 | 86 | continue; |
83 | 87 | } |
84 | - if (!$block) continue; |
|
88 | + if (!$block) |
|
89 | + { |
|
90 | + continue; |
|
91 | + } |
|
85 | 92 | |
86 | 93 | // got a complete block |
87 | 94 | if (in_array('posixGroup',$objectclasses)) |
@@ -93,7 +100,11 @@ discard block |
||
93 | 100 | // fall-through |
94 | 101 | case 'posixGroup': // nis |
95 | 102 | $objectclasses[] = $structural = 'groupOfNames'; |
96 | - if (!$members) $members[] = 'member: '.$dn; // member is a required attribute! |
|
103 | + if (!$members) |
|
104 | + { |
|
105 | + $members[] = 'member: '.$dn; |
|
106 | + } |
|
107 | + // member is a required attribute! |
|
97 | 108 | $data = array_merge($members,$data); |
98 | 109 | break; |
99 | 110 | case 'groupOfNames': // ok, already what we want |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | // raw replacements |
19 | 19 | $add_use_api = array( |
20 | - "#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below |
|
20 | + "#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below |
|
21 | 21 | "#<\?php\n+\s*/\*+?(.*)\*/#msU" => "<?php\n/**$1*/\n\nuse EGroupware\\Api;", |
22 | 22 | ); |
23 | 23 | $replace = array( |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // enclose class-names and static methods with some syntax check |
47 | 47 | $class_start = '#(?<!function)([\[\s,;().!=])'; |
48 | 48 | $class_end = '(::|\\(|\\)|;|\?|:|\\s|,|$)#'; |
49 | -foreach(array( |
|
49 | +foreach (array( |
|
50 | 50 | 'accounts' => 'Api\\Accounts', |
51 | 51 | 'acl' => 'Api\\Acl', |
52 | 52 | 'EGW_ACL_READ' => 'Api\\Acl::READ', |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
190 | 190 | * @return boolean false on error |
191 | 191 | */ |
192 | -function fix_api($file, $dry_run=false) |
|
192 | +function fix_api($file, $dry_run = false) |
|
193 | 193 | { |
194 | 194 | global $prog, $replace, $add_use_api; |
195 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
195 | + if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
196 | 196 | |
197 | 197 | if (($content = $content_in = file_get_contents($file)) === false) return false; |
198 | 198 | |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | } |
204 | 204 | $content2 = preg_replace(array_keys($replace), array_values($replace), $content); |
205 | 205 | |
206 | - if ($content2 == $content_in) return true; // nothing changed |
|
206 | + if ($content2 == $content_in) return true; // nothing changed |
|
207 | 207 | |
208 | 208 | $content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2); |
209 | 209 | |
210 | 210 | // shorten some classes, if used, with further use declarations |
211 | - foreach(array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace) |
|
211 | + foreach (array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace) |
|
212 | 212 | { |
213 | 213 | if (strpos($content, $namespace) !== false && strpos($content, 'use EGroupware\\'.$namespace) === false) |
214 | 214 | { |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
248 | 248 | * @return boolean false on error |
249 | 249 | */ |
250 | -function fix_api_recursive($dir, $dry_run=false) |
|
250 | +function fix_api_recursive($dir, $dry_run = false) |
|
251 | 251 | { |
252 | 252 | if (!is_dir($dir)) return false; |
253 | 253 | |
254 | - foreach(scandir($dir) as $file) |
|
254 | + foreach (scandir($dir) as $file) |
|
255 | 255 | { |
256 | 256 | if ($file == '.' || $file == '..') continue; |
257 | 257 | |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | { |
260 | 260 | fix_api_recursive($dir.'/'.$file, $dry_run); |
261 | 261 | } |
262 | - elseif(substr($file,-4) == '.php') |
|
262 | + elseif (substr($file, -4) == '.php') |
|
263 | 263 | { |
264 | - echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': '; |
|
264 | + echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': '; |
|
265 | 265 | fix_api($dir.'/'.$file, $dry_run); |
266 | 266 | } |
267 | 267 | } |
268 | - echo "\r".str_repeat(' ',100)."\r"; |
|
268 | + echo "\r".str_repeat(' ', 100)."\r"; |
|
269 | 269 | return true; |
270 | 270 | } |
271 | 271 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @param string $error =null |
276 | 276 | */ |
277 | -function usage($error=null) |
|
277 | +function usage($error = null) |
|
278 | 278 | { |
279 | 279 | global $prog; |
280 | 280 | echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n"; |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | if (!$args) usage(); |
289 | 289 | |
290 | 290 | $dry_run = false; |
291 | -while(($arg = array_shift($args)) && $arg[0] == '-') |
|
291 | +while (($arg = array_shift($args)) && $arg[0] == '-') |
|
292 | 292 | { |
293 | - switch($arg) |
|
293 | + switch ($arg) |
|
294 | 294 | { |
295 | 295 | case '-h': |
296 | 296 | case '--help': |
@@ -323,4 +323,4 @@ discard block |
||
323 | 323 | fix_api_recursive($arg, $dry_run); |
324 | 324 | } |
325 | 325 | } |
326 | -while(($arg = array_shift($args))); |
|
326 | +while (($arg = array_shift($args))); |
@@ -10,10 +10,13 @@ discard block |
||
10 | 10 | * @version $Id$ |
11 | 11 | */ |
12 | 12 | |
13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
13 | +if (php_sapi_name() !== 'cli') |
|
14 | +{ |
|
15 | + // security precaution: forbit calling as web-page |
|
14 | 16 | { |
15 | 17 | die('<h1>fix_api.php must NOT be called as web-page --> exiting !!!</h1>'); |
16 | 18 | } |
19 | +} |
|
17 | 20 | |
18 | 21 | // raw replacements |
19 | 22 | $add_use_api = array( |
@@ -192,9 +195,16 @@ discard block |
||
192 | 195 | function fix_api($file, $dry_run=false) |
193 | 196 | { |
194 | 197 | global $prog, $replace, $add_use_api; |
195 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
198 | + if (basename($file) == $prog) |
|
199 | + { |
|
200 | + return true; |
|
201 | + } |
|
202 | + // dont fix ourself ;-) |
|
196 | 203 | |
197 | - if (($content = $content_in = file_get_contents($file)) === false) return false; |
|
204 | + if (($content = $content_in = file_get_contents($file)) === false) |
|
205 | + { |
|
206 | + return false; |
|
207 | + } |
|
198 | 208 | |
199 | 209 | if (!preg_match("|<\?php\n+\s*/\*\*?.*\*/|msU", $content)) |
200 | 210 | { |
@@ -203,7 +213,11 @@ discard block |
||
203 | 213 | } |
204 | 214 | $content2 = preg_replace(array_keys($replace), array_values($replace), $content); |
205 | 215 | |
206 | - if ($content2 == $content_in) return true; // nothing changed |
|
216 | + if ($content2 == $content_in) |
|
217 | + { |
|
218 | + return true; |
|
219 | + } |
|
220 | + // nothing changed |
|
207 | 221 | |
208 | 222 | $content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2); |
209 | 223 | |
@@ -249,11 +263,17 @@ discard block |
||
249 | 263 | */ |
250 | 264 | function fix_api_recursive($dir, $dry_run=false) |
251 | 265 | { |
252 | - if (!is_dir($dir)) return false; |
|
266 | + if (!is_dir($dir)) |
|
267 | + { |
|
268 | + return false; |
|
269 | + } |
|
253 | 270 | |
254 | 271 | foreach(scandir($dir) as $file) |
255 | 272 | { |
256 | - if ($file == '.' || $file == '..') continue; |
|
273 | + if ($file == '.' || $file == '..') |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
257 | 277 | |
258 | 278 | if (is_dir($dir.'/'.$file)) |
259 | 279 | { |
@@ -278,14 +298,20 @@ discard block |
||
278 | 298 | { |
279 | 299 | global $prog; |
280 | 300 | echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n"; |
281 | - if ($error) echo $error."\n\n"; |
|
301 | + if ($error) |
|
302 | + { |
|
303 | + echo $error."\n\n"; |
|
304 | + } |
|
282 | 305 | exit($error ? 1 : 0); |
283 | 306 | } |
284 | 307 | |
285 | 308 | $args = $_SERVER['argv']; |
286 | 309 | $prog = basename(array_shift($args)); |
287 | 310 | |
288 | -if (!$args) usage(); |
|
311 | +if (!$args) |
|
312 | +{ |
|
313 | + usage(); |
|
314 | +} |
|
289 | 315 | |
290 | 316 | $dry_run = false; |
291 | 317 | while(($arg = array_shift($args)) && $arg[0] == '-') |
@@ -303,16 +329,22 @@ discard block |
||
303 | 329 | break; |
304 | 330 | |
305 | 331 | default: |
306 | - if ($args) // not last argument |
|
332 | + if ($args) |
|
333 | + { |
|
334 | + // not last argument |
|
307 | 335 | { |
308 | 336 | usage("Unknown argument '$arg'!"); |
309 | 337 | } |
338 | + } |
|
310 | 339 | break 2; |
311 | 340 | } |
312 | 341 | } |
313 | 342 | |
314 | 343 | do { |
315 | - if (!file_exists($arg)) usage("Error: $arg not found!"); |
|
344 | + if (!file_exists($arg)) |
|
345 | + { |
|
346 | + usage("Error: $arg not found!"); |
|
347 | + } |
|
316 | 348 | |
317 | 349 | if (!is_dir($arg)) |
318 | 350 | { |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | // Previously all portlets were together in a sub-array, for defaults they |
42 | 42 | // need to be moved to top level |
43 | 43 | $preferences = array(); |
44 | - foreach($GLOBALS['egw_setup']->db->select('egw_preferences','preference_owner,preference_app,preference_value',array( |
|
44 | + foreach ($GLOBALS['egw_setup']->db->select('egw_preferences', 'preference_owner,preference_app,preference_value', array( |
|
45 | 45 | 'preference_app' => 'home', |
46 | - ),__LINE__,__FILE__) as $row) |
|
46 | + ), __LINE__, __FILE__) as $row) |
|
47 | 47 | { |
48 | 48 | $preferences[] = $row; |
49 | 49 | } |
50 | - foreach($preferences as $row) |
|
50 | + foreach ($preferences as $row) |
|
51 | 51 | { |
52 | 52 | // The following replacement is required for PostgreSQL to work |
53 | 53 | $app = trim($row['preference_app']); |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | // Too old, skip it |
63 | 63 | continue; |
64 | 64 | } |
65 | - if($values['portlets'] && is_array($values['portlets'])) |
|
65 | + if ($values['portlets'] && is_array($values['portlets'])) |
|
66 | 66 | { |
67 | - foreach($values['portlets'] as $id => $settings) |
|
67 | + foreach ($values['portlets'] as $id => $settings) |
|
68 | 68 | { |
69 | 69 | $values["portlet_$id"] = $settings; |
70 | 70 | } |
71 | 71 | unset($values['portlets']); |
72 | 72 | } |
73 | 73 | $GLOBALS['egw_setup']->db->insert( |
74 | - 'egw_preferences',array( |
|
74 | + 'egw_preferences', array( |
|
75 | 75 | 'preference_value' => json_encode($values), |
76 | - ),array( |
|
76 | + ), array( |
|
77 | 77 | 'preference_owner' => $row['preference_owner'], |
78 | 78 | 'preference_app' => $app, |
79 | - ),__LINE__,__FILE__ |
|
79 | + ), __LINE__, __FILE__ |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | function home_upgrade14_1_001() |
92 | 92 | { |
93 | 93 | // rename "home-accounts" to "api-accounts" |
94 | - foreach(array('link_app1', 'link_app2') as $col) |
|
94 | + foreach (array('link_app1', 'link_app2') as $col) |
|
95 | 95 | { |
96 | 96 | $GLOBALS['egw_setup']->db->update('egw_links', array( |
97 | 97 | $col => 'api-accounts', |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Egroupware |
|
4 | - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
5 | - * @package home |
|
6 | - * @subpackage portlet |
|
7 | - * @link http://www.egroupware.org |
|
8 | - * @author Nathan Gray |
|
9 | - * @version $Id$ |
|
10 | - */ |
|
3 | + * Egroupware |
|
4 | + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
5 | + * @package home |
|
6 | + * @subpackage portlet |
|
7 | + * @link http://www.egroupware.org |
|
8 | + * @author Nathan Gray |
|
9 | + * @version $Id$ |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | use EGroupware\Api; |
13 | 13 | use EGroupware\Api\Etemplate; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | */ |
19 | 19 | class home_birthday_portlet extends home_portlet |
20 | -{ |
|
20 | + { |
|
21 | 21 | /** |
22 | 22 | * Constructor sets up the portlet according to the user's saved property values |
23 | 23 | * for this particular portlet. It is possible to have multiple instances of the |
@@ -32,7 +32,10 @@ discard block |
||
32 | 32 | public function __construct(Array &$context = array(), &$need_reload = false) |
33 | 33 | { |
34 | 34 | unset($need_reload); // not used, but required by function signature |
35 | - if (false) parent::__construct(); |
|
35 | + if (false) |
|
36 | + { |
|
37 | + parent::__construct(); |
|
38 | + } |
|
36 | 39 | |
37 | 40 | $this->context = $context; |
38 | 41 | } |
@@ -70,10 +73,13 @@ discard block |
||
70 | 73 | |
71 | 74 | $etemplate->read('home.birthdays'); |
72 | 75 | |
73 | - if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') // calendar Api\Config |
|
76 | + if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') |
|
77 | + { |
|
78 | + // calendar Api\Config |
|
74 | 79 | { |
75 | 80 | $content = $this->get_birthdays(); |
76 | 81 | } |
82 | + } |
|
77 | 83 | $etemplate->set_dom_id($id); |
78 | 84 | |
79 | 85 | $etemplate->exec('home.home_list_portlet.exec',$content); |
@@ -123,7 +129,10 @@ discard block |
||
123 | 129 | { |
124 | 130 | if(substr($contact['bday'],-6) == $day) |
125 | 131 | { |
126 | - if (!$ab_lang_loaded++) Api\Translation::add_app('addressbook'); |
|
132 | + if (!$ab_lang_loaded++) |
|
133 | + { |
|
134 | + Api\Translation::add_app('addressbook'); |
|
135 | + } |
|
127 | 136 | switch($n) |
128 | 137 | { |
129 | 138 | case 0: |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * @param context Array portlet settings such as size, as well as values for properties |
30 | 30 | * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called) |
31 | 31 | */ |
32 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
32 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
33 | 33 | { |
34 | 34 | unset($need_reload); // not used, but required by function signature |
35 | 35 | if (false) parent::__construct(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct(Array &$context = array(), &$need_reload = false) |
33 | 33 | { |
34 | - unset($need_reload); // not used, but required by function signature |
|
34 | + unset($need_reload); // not used, but required by function signature |
|
35 | 35 | if (false) parent::__construct(); |
36 | 36 | |
37 | 37 | $this->context = $context; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | $etemplate->set_dom_id($id); |
78 | 78 | |
79 | - $etemplate->exec('home.home_list_portlet.exec',$content); |
|
79 | + $etemplate->exec('home.home_list_portlet.exec', $content); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,30 +85,30 @@ discard block |
||
85 | 85 | protected function get_birthdays() |
86 | 86 | { |
87 | 87 | $contacts = new Api\Contacts(); |
88 | - $month_start = date('-m-',$contacts->now_su); |
|
88 | + $month_start = date('-m-', $contacts->now_su); |
|
89 | 89 | $days = $this->context['days']; |
90 | 90 | $birthdays = array(); |
91 | 91 | |
92 | - $bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family','','%'); |
|
92 | + $bdays = & $contacts->search(array('bday' => $month_start), array('id', 'n_family', 'n_given', 'bday'), 'n_given,n_family', '', '%'); |
|
93 | 93 | // search accounts too, if not stored in accounts repository |
94 | 94 | $extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) && |
95 | 95 | $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1'; |
96 | - if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'), |
|
97 | - 'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) |
|
96 | + if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start), array('id', 'n_family', 'n_given', 'bday'), |
|
97 | + 'n_given,n_family', '', '%', false, 'AND', false, array('owner' => 0)))) |
|
98 | 98 | { |
99 | - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); |
|
99 | + $bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2); |
|
100 | 100 | } |
101 | - if (($month_end = date('-m-',$contacts->now_su+$days*24*3600)) != $month_start) |
|
101 | + if (($month_end = date('-m-', $contacts->now_su + $days * 24 * 3600)) != $month_start) |
|
102 | 102 | { |
103 | - if (($bdays2 =& $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'),'n_given,n_family','','%'))) |
|
103 | + if (($bdays2 = & $contacts->search(array('bday' => $month_end), array('id', 'n_family', 'n_given', 'bday'), 'n_given,n_family', '', '%'))) |
|
104 | 104 | { |
105 | - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); |
|
105 | + $bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2); |
|
106 | 106 | } |
107 | 107 | // search accounts too, if not stored in accounts repository |
108 | - if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'), |
|
109 | - 'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) |
|
108 | + if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_end), array('id', 'n_family', 'n_given', 'bday'), |
|
109 | + 'n_given,n_family', '', '%', false, 'AND', false, array('owner' => 0)))) |
|
110 | 110 | { |
111 | - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); |
|
111 | + $bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | unset($bdays2); unset($extra_accounts_search); |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | if ($bdays) |
117 | 117 | { |
118 | 118 | $ab_lang_loaded = 0; |
119 | - for($n = 0; $n <= $days; ++$n) |
|
119 | + for ($n = 0; $n <= $days; ++$n) |
|
120 | 120 | { |
121 | - $day = date('-m-d',$contacts->now_su+$n*24*3600); |
|
122 | - foreach($bdays as $contact) |
|
121 | + $day = date('-m-d', $contacts->now_su + $n * 24 * 3600); |
|
122 | + foreach ($bdays as $contact) |
|
123 | 123 | { |
124 | - if(substr($contact['bday'],-6) == $day) |
|
124 | + if (substr($contact['bday'], -6) == $day) |
|
125 | 125 | { |
126 | 126 | if (!$ab_lang_loaded++) Api\Translation::add_app('addressbook'); |
127 | - switch($n) |
|
127 | + switch ($n) |
|
128 | 128 | { |
129 | 129 | case 0: |
130 | 130 | $text = lang("Today is %1's birthday!", $contact['n_given'].' '.$contact['n_family']); |
@@ -19,7 +19,7 @@ |
||
19 | 19 | ); |
20 | 20 | |
21 | 21 | include('../header.inc.php'); |
22 | -$GLOBALS['egw_info']['flags']['nonavbar']=false; |
|
22 | +$GLOBALS['egw_info']['flags']['nonavbar'] = false; |
|
23 | 23 | |
24 | 24 | // Home is treated specially, so a redirect won't work. |
25 | 25 | $home = new home_ui(); |
@@ -1420,7 +1420,7 @@ |
||
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 | } |
@@ -81,12 +81,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | 'saveas' => array( |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ), |
231 | 231 | // DRAG and DROP events |
232 | 232 | 'file_drag' => array( |
233 | - 'dragType' => array('file','link'), |
|
233 | + 'dragType' => array('file', 'link'), |
|
234 | 234 | 'type' => 'drag', |
235 | 235 | 'onExecute' => 'javaScript:app.filemanager.drag' |
236 | 236 | ), |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | 'order' => 0, |
275 | 275 | 'allowOnMultiple' => true, |
276 | 276 | ); |
277 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
277 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
278 | 278 | { |
279 | 279 | $actions['share']['children']['share_mail']['children']['mail_'.$mode] = array( |
280 | 280 | 'caption' => $data['label'], |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | // This would be done automatically, but we're overriding |
295 | - foreach($actions as $action_id => $action) |
|
295 | + foreach ($actions as $action_id => $action) |
|
296 | 296 | { |
297 | - if($action['type'] == 'drop' && $action['caption']) |
|
297 | + if ($action['type'] == 'drop' && $action['caption']) |
|
298 | 298 | { |
299 | 299 | $action['type'] = 'popup'; |
300 | - if($action['acceptedTypes'] == 'file') |
|
300 | + if ($action['acceptedTypes'] == 'file') |
|
301 | 301 | { |
302 | 302 | $action['enabled'] = 'javaScript:app.filemanager.paste_enabled'; |
303 | 303 | } |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string merge application or NULL if no property found |
319 | 319 | */ |
320 | - private static function get_mergeapp($path, $scope='self') |
|
320 | + private static function get_mergeapp($path, $scope = 'self') |
|
321 | 321 | { |
322 | 322 | $app = null; |
323 | - switch($scope) |
|
323 | + switch ($scope) |
|
324 | 324 | { |
325 | 325 | case 'self': |
326 | 326 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | case 'parents': |
330 | 330 | // search for props in parent directories |
331 | 331 | $currentpath = $path; |
332 | - while($dir = Vfs::dirname($currentpath)) |
|
332 | + while ($dir = Vfs::dirname($currentpath)) |
|
333 | 333 | { |
334 | 334 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
335 | - if(!empty($props)) |
|
335 | + if (!empty($props)) |
|
336 | 336 | { |
337 | 337 | // found prop in parent directory |
338 | 338 | return $app = $props[0]['val']; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param array $content |
352 | 352 | * @param string $msg |
353 | 353 | */ |
354 | - function index(array $content=null,$msg=null) |
|
354 | + function index(array $content = null, $msg = null) |
|
355 | 355 | { |
356 | 356 | if (!is_array($content)) |
357 | 357 | { |
@@ -361,16 +361,16 @@ discard block |
||
361 | 361 | if (!is_array($content['nm'])) |
362 | 362 | { |
363 | 363 | $content['nm'] = array( |
364 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
365 | - 'filter' => '', // current dir only |
|
366 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
367 | - 'no_cat' => True, // I disable the cat-selectbox |
|
368 | - 'lettersearch' => True, // I show a lettersearch |
|
369 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
370 | - 'start' => 0, // IO position in list |
|
371 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
372 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
373 | - '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 |
|
364 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
365 | + 'filter' => '', // current dir only |
|
366 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
367 | + 'no_cat' => True, // I disable the cat-selectbox |
|
368 | + 'lettersearch' => True, // I show a lettersearch |
|
369 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
370 | + 'start' => 0, // IO position in list |
|
371 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
372 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
373 | + '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 |
|
374 | 374 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
375 | 375 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
376 | 376 | 'row_id' => 'path', |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $content['nm']['actions'] = static::get_actions(); |
385 | 385 | $content['nm']['home_dir'] = static::get_home_dir(); |
386 | 386 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
387 | - $content['nm']['placeholder_actions'] = array('mkdir','paste','share','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink'); |
|
387 | + $content['nm']['placeholder_actions'] = array('mkdir', 'paste', 'share', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink'); |
|
388 | 388 | |
389 | 389 | if (isset($_GET['msg'])) $msg = $_GET['msg']; |
390 | 390 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | } |
401 | 401 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
402 | 402 | { |
403 | - switch($path) |
|
403 | + switch ($path) |
|
404 | 404 | { |
405 | 405 | case '..': |
406 | 406 | $path = Vfs::dirname($content['nm']['path']); |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | $path = static::get_home_dir(); |
410 | 410 | break; |
411 | 411 | } |
412 | - if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
412 | + if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
413 | 413 | { |
414 | 414 | $content['nm']['path'] = $path; |
415 | 415 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | } |
426 | 426 | $view = static::get_view(); |
427 | 427 | |
428 | - call_user_func($view,$content,$msg); |
|
428 | + call_user_func($view, $content, $msg); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
439 | 439 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
440 | 440 | */ |
441 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
441 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
442 | 442 | { |
443 | 443 | if (!$user) |
444 | 444 | { |
@@ -447,15 +447,15 @@ discard block |
||
447 | 447 | else |
448 | 448 | { |
449 | 449 | // config user & password |
450 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
450 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
451 | 451 | // or vfs root user from setup >> configuration |
452 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
453 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
452 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
453 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
454 | 454 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
455 | 455 | } |
456 | 456 | //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)); |
457 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
458 | - Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
457 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
458 | + Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
459 | 459 | return Vfs::$is_root; |
460 | 460 | } |
461 | 461 | |
@@ -465,18 +465,18 @@ discard block |
||
465 | 465 | * @param array $content |
466 | 466 | * @param string $msg |
467 | 467 | */ |
468 | - function listview(array $content=null,$msg=null) |
|
468 | + function listview(array $content = null, $msg = null) |
|
469 | 469 | { |
470 | 470 | $tpl = new Etemplate('filemanager.index'); |
471 | 471 | |
472 | - if($msg) Framework::message($msg); |
|
472 | + if ($msg) Framework::message($msg); |
|
473 | 473 | |
474 | 474 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
475 | 475 | { |
476 | 476 | if ($content['nm']['action']) |
477 | 477 | { |
478 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
479 | - if($msg) Framework::message($msg); |
|
478 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
479 | + if ($msg) Framework::message($msg); |
|
480 | 480 | |
481 | 481 | // clean up after action |
482 | 482 | unset($content['nm']['selected']); |
@@ -487,10 +487,10 @@ discard block |
||
487 | 487 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
488 | 488 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
489 | 489 | } |
490 | - elseif($content['nm']['rows']['delete']) |
|
490 | + elseif ($content['nm']['rows']['delete']) |
|
491 | 491 | { |
492 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
493 | - if($msg) Framework::message($msg); |
|
492 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
493 | + if ($msg) Framework::message($msg); |
|
494 | 494 | |
495 | 495 | // clean up after action |
496 | 496 | unset($content['nm']['rows']['delete']); |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
503 | 503 | } |
504 | 504 | unset($content['nm']['rows']); |
505 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
505 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | // be tolerant with (in previous versions) not correct urlencoded pathes |
509 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
509 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
510 | 510 | { |
511 | 511 | $content['nm']['path'] = urldecode($content['nm']['path']); |
512 | 512 | } |
@@ -517,22 +517,22 @@ discard block |
||
517 | 517 | $button = key($content['button']); |
518 | 518 | unset($content['button']); |
519 | 519 | } |
520 | - switch($button) |
|
520 | + switch ($button) |
|
521 | 521 | { |
522 | 522 | case 'upload': |
523 | 523 | if (!$content['upload']) |
524 | 524 | { |
525 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
525 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
526 | 526 | break; |
527 | 527 | } |
528 | 528 | $upload_success = $upload_failure = array(); |
529 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
529 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
530 | 530 | { |
531 | 531 | // encode chars which special meaning in url/vfs (some like / get removed!) |
532 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
532 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
533 | 533 | if ($upload && |
534 | 534 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
535 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
535 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
536 | 536 | { |
537 | 537 | $upload_success[] = $upload['name']; |
538 | 538 | } |
@@ -544,12 +544,11 @@ discard block |
||
544 | 544 | $content['nm']['msg'] = ''; |
545 | 545 | if ($upload_success) |
546 | 546 | { |
547 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
548 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
547 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
549 | 548 | } |
550 | 549 | if ($upload_failure) |
551 | 550 | { |
552 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
551 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
553 | 552 | } |
554 | 553 | break; |
555 | 554 | } |
@@ -573,16 +572,16 @@ discard block |
||
573 | 572 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
574 | 573 | } |
575 | 574 | // Set view button to match current settings |
576 | - if($content['nm']['view'] == 'tile') |
|
575 | + if ($content['nm']['view'] == 'tile') |
|
577 | 576 | { |
578 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
579 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
577 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
578 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
580 | 579 | } |
581 | 580 | // if initial load is done via GET request (idots template or share.php) |
582 | 581 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
583 | 582 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
584 | 583 | |
585 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
584 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
586 | 585 | } |
587 | 586 | |
588 | 587 | /** |
@@ -618,7 +617,7 @@ discard block |
||
618 | 617 | * @param int &$files=null on return number of files deleted |
619 | 618 | * @return string success or failure message displayed to the user |
620 | 619 | */ |
621 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
620 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
622 | 621 | { |
623 | 622 | if (!count($selected)) |
624 | 623 | { |
@@ -626,20 +625,20 @@ discard block |
||
626 | 625 | } |
627 | 626 | $errs = $dirs = $files = 0; |
628 | 627 | |
629 | - switch($action) |
|
628 | + switch ($action) |
|
630 | 629 | { |
631 | 630 | |
632 | 631 | case 'delete': |
633 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
632 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
634 | 633 | |
635 | 634 | case 'mail': |
636 | 635 | case 'copy': |
637 | - foreach($selected as $path) |
|
636 | + foreach ($selected as $path) |
|
638 | 637 | { |
639 | 638 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
640 | 639 | { |
641 | 640 | // Support for dropping mail in filemanager - Pass mail back to mail app |
642 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessages', $path, $dir)) |
|
641 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessages', $path, $dir)) |
|
643 | 642 | { |
644 | 643 | ++$files; |
645 | 644 | } |
@@ -650,8 +649,8 @@ discard block |
||
650 | 649 | } |
651 | 650 | elseif (!Vfs::is_dir($path)) |
652 | 651 | { |
653 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
654 | - if ($path != $to && Vfs::copy($path,$to)) |
|
652 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
653 | + if ($path != $to && Vfs::copy($path, $to)) |
|
655 | 654 | { |
656 | 655 | ++$files; |
657 | 656 | } |
@@ -663,19 +662,19 @@ discard block |
||
663 | 662 | else |
664 | 663 | { |
665 | 664 | $len = strlen(dirname($path)); |
666 | - foreach(Vfs::find($path) as $p) |
|
665 | + foreach (Vfs::find($path) as $p) |
|
667 | 666 | { |
668 | - $to = $dir.substr($p,$len); |
|
667 | + $to = $dir.substr($p, $len); |
|
669 | 668 | if ($to == $p) // cant copy into itself! |
670 | 669 | { |
671 | 670 | ++$errs; |
672 | 671 | continue; |
673 | 672 | } |
674 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
673 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
675 | 674 | { |
676 | 675 | ++$dirs; |
677 | 676 | } |
678 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
677 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
679 | 678 | { |
680 | 679 | ++$files; |
681 | 680 | } |
@@ -688,15 +687,15 @@ discard block |
||
688 | 687 | } |
689 | 688 | if ($errs) |
690 | 689 | { |
691 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
690 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
692 | 691 | } |
693 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
692 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
694 | 693 | |
695 | 694 | case 'move': |
696 | - foreach($selected as $path) |
|
695 | + foreach ($selected as $path) |
|
697 | 696 | { |
698 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
699 | - if ($path != $to && Vfs::rename($path,$to)) |
|
697 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
698 | + if ($path != $to && Vfs::rename($path, $to)) |
|
700 | 699 | { |
701 | 700 | ++$files; |
702 | 701 | } |
@@ -707,17 +706,17 @@ discard block |
||
707 | 706 | } |
708 | 707 | if ($errs) |
709 | 708 | { |
710 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
709 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
711 | 710 | } |
712 | - return lang('%1 files moved.',$files); |
|
711 | + return lang('%1 files moved.', $files); |
|
713 | 712 | |
714 | 713 | case 'symlink': // symlink given files to $dir |
715 | - foreach((array)$selected as $target) |
|
714 | + foreach ((array)$selected as $target) |
|
716 | 715 | { |
717 | 716 | $link = Vfs::concat($dir, Vfs::basename($target)); |
718 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
717 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
719 | 718 | { |
720 | - if(!$ok) |
|
719 | + if (!$ok) |
|
721 | 720 | { |
722 | 721 | $errs++; |
723 | 722 | continue; |
@@ -739,15 +738,14 @@ discard block |
||
739 | 738 | } |
740 | 739 | if (count((array)$selected) == 1) |
741 | 740 | { |
742 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
743 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
741 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
744 | 742 | } |
745 | 743 | $ret = lang('%1 elements linked.', $files); |
746 | 744 | if ($errs) |
747 | 745 | { |
748 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
746 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
749 | 747 | } |
750 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
748 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
751 | 749 | |
752 | 750 | case 'createdir': |
753 | 751 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -763,13 +761,13 @@ discard block |
||
763 | 761 | |
764 | 762 | default: |
765 | 763 | list($action, $settings) = explode('_', $action, 2); |
766 | - switch($action) |
|
764 | + switch ($action) |
|
767 | 765 | { |
768 | 766 | case 'document': |
769 | 767 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
770 | 768 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
771 | 769 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
772 | - if($msg) return $msg; |
|
770 | + if ($msg) return $msg; |
|
773 | 771 | $errs = count($selected); |
774 | 772 | return false; |
775 | 773 | } |
@@ -786,12 +784,12 @@ discard block |
||
786 | 784 | * @param int &$files=null on return number of files deleted |
787 | 785 | * @return string |
788 | 786 | */ |
789 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
787 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
790 | 788 | { |
791 | 789 | $dirs = $files = $errs = 0; |
792 | 790 | // we first delete all selected links (and files) |
793 | 791 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
794 | - foreach($selected as $key => $path) |
|
792 | + foreach ($selected as $key => $path) |
|
795 | 793 | { |
796 | 794 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
797 | 795 | { |
@@ -809,21 +807,21 @@ discard block |
||
809 | 807 | if ($selected) // somethings left to delete |
810 | 808 | { |
811 | 809 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
812 | - foreach((array)$selected as $path) |
|
810 | + foreach ((array)$selected as $path) |
|
813 | 811 | { |
814 | 812 | if (Vfs::isProtectedDir($path)) |
815 | 813 | { |
816 | 814 | $errs++; |
817 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
815 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
818 | 816 | } |
819 | 817 | } |
820 | 818 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
821 | 819 | // - depth=true to get first the files and then the dir containing it |
822 | 820 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
823 | 821 | // - show-deleted=false to not (finally) deleted versioned files |
824 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
822 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
825 | 823 | { |
826 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
824 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
827 | 825 | { |
828 | 826 | ++$dirs; |
829 | 827 | } |
@@ -839,13 +837,13 @@ discard block |
||
839 | 837 | } |
840 | 838 | if ($errs) |
841 | 839 | { |
842 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
840 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
843 | 841 | } |
844 | 842 | if ($dirs) |
845 | 843 | { |
846 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
844 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
847 | 845 | } |
848 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
846 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
849 | 847 | } |
850 | 848 | |
851 | 849 | /** |
@@ -860,37 +858,37 @@ discard block |
||
860 | 858 | if (!$query['csv_export']) |
861 | 859 | { |
862 | 860 | Api\Cache::setSession('filemanager', 'index', |
863 | - array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
|
861 | + array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
864 | 862 | } |
865 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
863 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
866 | 864 | |
867 | 865 | // Change template to match selected view |
868 | - if($query['view']) |
|
866 | + if ($query['view']) |
|
869 | 867 | { |
870 | 868 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
871 | 869 | |
872 | 870 | // Store as preference but only for index, not home |
873 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
871 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
874 | 872 | { |
875 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
873 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
876 | 874 | $GLOBALS['egw']->preferences->save_repository(); |
877 | 875 | } |
878 | 876 | } |
879 | 877 | // be tolerant with (in previous versions) not correct urlencoded pathes |
880 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
878 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
881 | 879 | { |
882 | 880 | $query['path'] = urldecode($query['path']); |
883 | 881 | } |
884 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
882 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
885 | 883 | { |
886 | 884 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
887 | 885 | if ($query['path'] != ($path = static::get_home_dir())) |
888 | 886 | { |
889 | 887 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
890 | 888 | // an appropriate message |
891 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
889 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
892 | 890 | 'path' => $path, |
893 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
891 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
894 | 892 | 'ajax' => 'true' |
895 | 893 | )); |
896 | 894 | } |
@@ -900,7 +898,7 @@ discard block |
||
900 | 898 | $GLOBALS['egw']->session->commit_session(); |
901 | 899 | $rows = $dir_is_writable = array(); |
902 | 900 | $vfs_options = $this->get_vfs_options($query); |
903 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
901 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
904 | 902 | { |
905 | 903 | //echo $path; _debug_array($row); |
906 | 904 | |
@@ -918,7 +916,7 @@ discard block |
||
918 | 916 | |
919 | 917 | $row['class'] .= 'isDir '; |
920 | 918 | $row['is_dir'] = 1; |
921 | - if(!$dir_is_writable[$path]) |
|
919 | + if (!$dir_is_writable[$path]) |
|
922 | 920 | { |
923 | 921 | $row['class'] .= 'noEdit '; |
924 | 922 | } |
@@ -930,32 +928,32 @@ discard block |
||
930 | 928 | |
931 | 929 | $row['class'] .= !$dir_is_writable[$dir] ? 'noDelete' : ''; |
932 | 930 | $row['download_url'] = Vfs::download_url($path); |
933 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
931 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
934 | 932 | |
935 | 933 | $rows[++$n] = $row; |
936 | 934 | $path2n[$path] = $n; |
937 | 935 | } |
938 | 936 | // query comments and cf's for the displayed rows |
939 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
937 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
940 | 938 | |
941 | 939 | // Always include comment in tiles |
942 | - if($query['view'] == 'tile') |
|
940 | + if ($query['view'] == 'tile') |
|
943 | 941 | { |
944 | 942 | $cols_to_show[] = 'comment'; |
945 | 943 | } |
946 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
947 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
944 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
945 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
948 | 946 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
949 | 947 | { |
950 | - foreach($path2props as $path => $props) |
|
948 | + foreach ($path2props as $path => $props) |
|
951 | 949 | { |
952 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
953 | - $row =& $rows[$path2n[$path]]; |
|
954 | - if ( !is_array($props) ) continue; |
|
955 | - foreach($props as $prop) |
|
950 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
951 | + $row = & $rows[$path2n[$path]]; |
|
952 | + if (!is_array($props)) continue; |
|
953 | + foreach ($props as $prop) |
|
956 | 954 | { |
957 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
958 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
955 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
956 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
959 | 957 | } |
960 | 958 | } |
961 | 959 | } |
@@ -967,7 +965,7 @@ discard block |
||
967 | 965 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
968 | 966 | { |
969 | 967 | // we need our app.css file |
970 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
968 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
971 | 969 | { |
972 | 970 | $css_file = '/filemanager/templates/default/app.css'; |
973 | 971 | } |
@@ -983,35 +981,35 @@ discard block |
||
983 | 981 | */ |
984 | 982 | protected function get_vfs_options($query) |
985 | 983 | { |
986 | - if($query['searchletter'] && !empty($query['search'])) |
|
984 | + if ($query['searchletter'] && !empty($query['search'])) |
|
987 | 985 | { |
988 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
986 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
989 | 987 | if ($query['searchletter'] == strtolower($query['search'][0])) |
990 | 988 | { |
991 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
992 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
989 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
990 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
993 | 991 | } |
994 | 992 | } |
995 | 993 | elseif ($query['searchletter']) |
996 | 994 | { |
997 | 995 | $namefilter = '/^'.$query['searchletter'].'/i'; |
998 | 996 | } |
999 | - elseif(!empty($query['search'])) |
|
997 | + elseif (!empty($query['search'])) |
|
1000 | 998 | { |
1001 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
999 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
1002 | 1000 | } |
1003 | 1001 | |
1004 | 1002 | // Re-map so 'No filters' favorite ('') is depth 1 |
1005 | 1003 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
1006 | 1004 | |
1007 | 1005 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
1008 | - if($filter == 5) $maxdepth = 2; |
|
1006 | + if ($filter == 5) $maxdepth = 2; |
|
1009 | 1007 | $n = 0; |
1010 | 1008 | $vfs_options = array( |
1011 | 1009 | 'mindepth' => 1, |
1012 | 1010 | 'maxdepth' => $maxdepth, |
1013 | 1011 | 'dirsontop' => $filter <= 1, |
1014 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
1012 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
1015 | 1013 | 'order' => $query['order'], 'sort' => $query['sort'], |
1016 | 1014 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
1017 | 1015 | 'need_mime' => true, |
@@ -1019,7 +1017,7 @@ discard block |
||
1019 | 1017 | 'hidden' => $filter == 3, |
1020 | 1018 | 'follow' => $filter == 5, |
1021 | 1019 | ); |
1022 | - if($query['col_filter']['mime']) |
|
1020 | + if ($query['col_filter']['mime']) |
|
1023 | 1021 | { |
1024 | 1022 | $vfs_options['mime'] = $query['col_filter']['mime']; |
1025 | 1023 | } |
@@ -1033,7 +1031,7 @@ discard block |
||
1033 | 1031 | * @param array $content |
1034 | 1032 | * @param string $msg |
1035 | 1033 | */ |
1036 | - function file(array $content=null,$msg='') |
|
1034 | + function file(array $content = null, $msg = '') |
|
1037 | 1035 | { |
1038 | 1036 | $tpl = new Etemplate('filemanager.file'); |
1039 | 1037 | |
@@ -1043,9 +1041,9 @@ discard block |
||
1043 | 1041 | { |
1044 | 1042 | $msg .= $_GET['msg']; |
1045 | 1043 | } |
1046 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
1044 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
1047 | 1045 | // actions enclose pathes containing comma with " |
1048 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
1046 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
1049 | 1047 | !($stat = Vfs::lstat($path))) |
1050 | 1048 | { |
1051 | 1049 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -1058,10 +1056,10 @@ discard block |
||
1058 | 1056 | $content['path'] = $path; |
1059 | 1057 | $content['hsize'] = Vfs::hsize($stat['size']); |
1060 | 1058 | $content['mime'] = Vfs::mime_content_type($path); |
1061 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
1059 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
1062 | 1060 | if (($props = Vfs::propfind($path))) |
1063 | 1061 | { |
1064 | - foreach($props as $prop) |
|
1062 | + foreach ($props as $prop) |
|
1065 | 1063 | { |
1066 | 1064 | $content[$prop['name']] = $prop['val']; |
1067 | 1065 | } |
@@ -1074,9 +1072,9 @@ discard block |
||
1074 | 1072 | $content['tabs'] = $_GET['tabs']; |
1075 | 1073 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
1076 | 1074 | { |
1077 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
1075 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
1078 | 1076 | $mask = 6; |
1079 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
1077 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
1080 | 1078 | { |
1081 | 1079 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
1082 | 1080 | } |
@@ -1086,20 +1084,20 @@ discard block |
||
1086 | 1084 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
1087 | 1085 | $mask = 7; |
1088 | 1086 | } |
1089 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
1087 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
1090 | 1088 | { |
1091 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
1089 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
1092 | 1090 | } |
1093 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
1091 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
1094 | 1092 | } |
1095 | 1093 | else |
1096 | 1094 | { |
1097 | 1095 | //_debug_array($content); |
1098 | - $path =& $content['path']; |
|
1096 | + $path = & $content['path']; |
|
1099 | 1097 | |
1100 | 1098 | $button = @key($content['button']); |
1101 | 1099 | unset($content['button']); |
1102 | - if(!$button && $content['sudo']) |
|
1100 | + if (!$button && $content['sudo']) |
|
1103 | 1101 | { |
1104 | 1102 | // Button to stop sudo is not in button namespace |
1105 | 1103 | $button = 'sudo'; |
@@ -1108,21 +1106,21 @@ discard block |
||
1108 | 1106 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
1109 | 1107 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
1110 | 1108 | { |
1111 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
1109 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
1112 | 1110 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
1113 | 1111 | lang('Wrong username or password!') : lang('Root access stopped.')); |
1114 | 1112 | unset($content['sudo']); |
1115 | 1113 | $content['is_owner'] = Vfs::has_owner_rights($path); |
1116 | 1114 | } |
1117 | - if (in_array($button,array('save','apply'))) |
|
1115 | + if (in_array($button, array('save', 'apply'))) |
|
1118 | 1116 | { |
1119 | 1117 | $props = array(); |
1120 | 1118 | $perm_changed = $perm_failed = 0; |
1121 | - foreach($content['old'] as $name => $old_value) |
|
1119 | + foreach ($content['old'] as $name => $old_value) |
|
1122 | 1120 | { |
1123 | 1121 | if (isset($content[$name]) && ($old_value != $content[$name] || |
1124 | 1122 | // do not check for modification, if modify_subs is checked! |
1125 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
1123 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
1126 | 1124 | ($name != 'uid' || Vfs::$is_root)) |
1127 | 1125 | { |
1128 | 1126 | if ($name == 'name') |
@@ -1136,23 +1134,23 @@ discard block |
||
1136 | 1134 | $to = Vfs::concat($dir, $content['name']); |
1137 | 1135 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
1138 | 1136 | { |
1139 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
1140 | - lang('To overwrite the existing file store again.',lang($button))); |
|
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))); |
|
1141 | 1139 | $content['confirm_overwrite'] = $to; |
1142 | 1140 | if ($button == 'save') $button = 'apply'; |
1143 | 1141 | continue; |
1144 | 1142 | } |
1145 | - if (Vfs::rename($path,$to)) |
|
1143 | + if (Vfs::rename($path, $to)) |
|
1146 | 1144 | { |
1147 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1145 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1148 | 1146 | $content['old']['name'] = $content[$name]; |
1149 | 1147 | $path = $to; |
1150 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1151 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1148 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1149 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1152 | 1150 | } |
1153 | 1151 | else |
1154 | 1152 | { |
1155 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1153 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1156 | 1154 | if (Vfs::deny_script($to)) |
1157 | 1155 | { |
1158 | 1156 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1172,7 +1170,7 @@ discard block |
||
1172 | 1170 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
1173 | 1171 | ), |
1174 | 1172 | ); |
1175 | - if (Vfs::proppatch($path,$mergeprop)) |
|
1173 | + if (Vfs::proppatch($path, $mergeprop)) |
|
1176 | 1174 | { |
1177 | 1175 | $content['old'][$name] = $content[$name]; |
1178 | 1176 | $msg .= lang('Setting for document merge saved.'); |
@@ -1184,22 +1182,22 @@ discard block |
||
1184 | 1182 | } |
1185 | 1183 | else |
1186 | 1184 | { |
1187 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
1188 | - $cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]); |
|
1185 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
1186 | + $cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]); |
|
1189 | 1187 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
1190 | 1188 | if ($content['modify_subs']) |
1191 | 1189 | { |
1192 | 1190 | if ($name == 'perms') |
1193 | 1191 | { |
1194 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
1195 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
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 |
|
1196 | 1194 | } |
1197 | 1195 | else |
1198 | 1196 | { |
1199 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
1197 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
1200 | 1198 | } |
1201 | 1199 | $ok = $failed = 0; |
1202 | - foreach($changed as &$r) |
|
1200 | + foreach ($changed as &$r) |
|
1203 | 1201 | { |
1204 | 1202 | if ($r) |
1205 | 1203 | { |
@@ -1212,32 +1210,32 @@ discard block |
||
1212 | 1210 | } |
1213 | 1211 | if ($ok && !$failed) |
1214 | 1212 | { |
1215 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1213 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
1216 | 1214 | $content['old'][$name] = $content[$name]; |
1217 | 1215 | } |
1218 | - elseif($failed) |
|
1216 | + elseif ($failed) |
|
1219 | 1217 | { |
1220 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1221 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
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).')' : '')); |
|
1222 | 1220 | } |
1223 | 1221 | } |
1224 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
1222 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
1225 | 1223 | { |
1226 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
1224 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
1227 | 1225 | $content['old'][$name] = $content[$name]; |
1228 | 1226 | } |
1229 | 1227 | else |
1230 | 1228 | { |
1231 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
1229 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
1232 | 1230 | } |
1233 | 1231 | } |
1234 | 1232 | } |
1235 | 1233 | } |
1236 | 1234 | if ($props) |
1237 | 1235 | { |
1238 | - if (Vfs::proppatch($path,$props)) |
|
1236 | + if (Vfs::proppatch($path, $props)) |
|
1239 | 1237 | { |
1240 | - foreach($props as $prop) |
|
1238 | + foreach ($props as $prop) |
|
1241 | 1239 | { |
1242 | 1240 | $content['old'][$prop['name']] = $prop['val']; |
1243 | 1241 | } |
@@ -1254,8 +1252,8 @@ discard block |
||
1254 | 1252 | if ($content['eacl']['delete']) |
1255 | 1253 | { |
1256 | 1254 | $ino_owner = key($content['eacl']['delete']); |
1257 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
1258 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
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!'); |
|
1259 | 1257 | } |
1260 | 1258 | elseif ($button == 'eacl') |
1261 | 1259 | { |
@@ -1265,7 +1263,7 @@ discard block |
||
1265 | 1263 | } |
1266 | 1264 | else |
1267 | 1265 | { |
1268 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
1266 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
1269 | 1267 | lang('ACL added.') : lang('Error adding the ACL!'); |
1270 | 1268 | } |
1271 | 1269 | } |
@@ -1275,7 +1273,7 @@ discard block |
||
1275 | 1273 | } |
1276 | 1274 | if ($content['is_link'] && !Vfs::stat($path)) |
1277 | 1275 | { |
1278 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
1276 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
1279 | 1277 | } |
1280 | 1278 | $content['link'] = Egw::link(Vfs::download_url($path)); |
1281 | 1279 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1284,11 +1282,11 @@ discard block |
||
1284 | 1282 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
1285 | 1283 | // only owner can change group & perms |
1286 | 1284 | if (($readonlys['gid'] = !$content['is_owner'] || |
1287 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs |
|
1285 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs') || // no uid, gid or perms in oldvfs |
|
1288 | 1286 | !Vfs::is_writable($path)) |
1289 | 1287 | { |
1290 | 1288 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1291 | - foreach($content['perms'] as $name => $value) |
|
1289 | + foreach ($content['perms'] as $name => $value) |
|
1292 | 1290 | { |
1293 | 1291 | $readonlys['perms['.$name.']'] = true; |
1294 | 1292 | } |
@@ -1307,38 +1305,38 @@ discard block |
||
1307 | 1305 | } |
1308 | 1306 | elseif (!Vfs::is_writable($path)) |
1309 | 1307 | { |
1310 | - foreach($cfs as $name => $data) |
|
1308 | + foreach ($cfs as $name => $data) |
|
1311 | 1309 | { |
1312 | 1310 | $readonlys['#'.$name] = true; |
1313 | 1311 | } |
1314 | 1312 | } |
1315 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1313 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1316 | 1314 | if ($content['is_dir']) |
1317 | 1315 | { |
1318 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1319 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
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( |
|
1320 | 1318 | 7 => lang('Display and modification of content'), |
1321 | 1319 | 5 => lang('Display of content'), |
1322 | 1320 | 0 => lang('No access'), |
1323 | 1321 | ); |
1324 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl |
|
1322 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl |
|
1325 | 1323 | $GLOBALS['egw_info']['user']['account_id'] == Vfs::$user) // leave eACL tab disabled for sharing |
1326 | 1324 | { |
1327 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1328 | - foreach($content['eacl'] as &$eacl) |
|
1325 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1326 | + foreach ($content['eacl'] as &$eacl) |
|
1329 | 1327 | { |
1330 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
1328 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
1331 | 1329 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
1332 | 1330 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
1333 | 1331 | } |
1334 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
1332 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
1335 | 1333 | $content['eacl']['owner'] = 0; |
1336 | 1334 | $content['eacl']['rights'] = 5; |
1337 | 1335 | } |
1338 | 1336 | } |
1339 | 1337 | else |
1340 | 1338 | { |
1341 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1339 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1342 | 1340 | 6 => lang('Read & write access'), |
1343 | 1341 | 4 => lang('Read access only'), |
1344 | 1342 | 0 => lang('No access'), |
@@ -1348,11 +1346,11 @@ discard block |
||
1348 | 1346 | // mergeapp |
1349 | 1347 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
1350 | 1348 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
1351 | - if(!empty($content['mergeapp'])) |
|
1349 | + if (!empty($content['mergeapp'])) |
|
1352 | 1350 | { |
1353 | 1351 | $content['mergeapp_effective'] = $content['mergeapp']; |
1354 | 1352 | } |
1355 | - elseif(!empty($content['mergeapp_parent'])) |
|
1353 | + elseif (!empty($content['mergeapp_parent'])) |
|
1356 | 1354 | { |
1357 | 1355 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
1358 | 1356 | } |
@@ -1364,7 +1362,7 @@ discard block |
||
1364 | 1362 | $mergeapp_list = Link::app_list('merge'); |
1365 | 1363 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
1366 | 1364 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
1367 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
1365 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
1368 | 1366 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
1369 | 1367 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
1370 | 1368 | // mergeapp other gui options |
@@ -1381,7 +1379,7 @@ discard block |
||
1381 | 1379 | 'comment' => (string)$content['comment'], |
1382 | 1380 | 'mergeapp' => $content['mergeapp'] |
1383 | 1381 | ); |
1384 | - if ($cfs) foreach($cfs as $name => $data) |
|
1382 | + if ($cfs) foreach ($cfs as $name => $data) |
|
1385 | 1383 | { |
1386 | 1384 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1387 | 1385 | } |
@@ -1389,31 +1387,31 @@ discard block |
||
1389 | 1387 | if (Vfs::$is_root) |
1390 | 1388 | { |
1391 | 1389 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
1392 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
1390 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
1393 | 1391 | // Need a more complex submit because button type is buttononly, which doesn't submit |
1394 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
1392 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
1395 | 1393 | |
1396 | 1394 | } |
1397 | 1395 | elseif ($button == 'sudo') |
1398 | 1396 | { |
1399 | 1397 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
1400 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
1401 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
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")'); |
|
1402 | 1400 | } |
1403 | 1401 | else if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id'])) |
1404 | 1402 | { |
1405 | 1403 | // Just hide sudo for anonymous users |
1406 | 1404 | $readonlys['sudouser'] = true; |
1407 | 1405 | } |
1408 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
1406 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
1409 | 1407 | { |
1410 | 1408 | // add to existing tabs in template |
1411 | 1409 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1412 | 1410 | |
1413 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
1411 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
1414 | 1412 | if (true) $tabs = array(); |
1415 | 1413 | |
1416 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1414 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1417 | 1415 | { |
1418 | 1416 | $tabs[] = array( |
1419 | 1417 | 'label' => $extra_tab['label'], |
@@ -1436,7 +1434,7 @@ discard block |
||
1436 | 1434 | Framework::window_focus(); |
1437 | 1435 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
1438 | 1436 | |
1439 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
1437 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
1440 | 1438 | } |
1441 | 1439 | |
1442 | 1440 | /** |
@@ -1458,7 +1456,7 @@ discard block |
||
1458 | 1456 | * @param string $dir=null current directory |
1459 | 1457 | * @see static::action() |
1460 | 1458 | */ |
1461 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
1459 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
1462 | 1460 | { |
1463 | 1461 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
1464 | 1462 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1477,15 +1475,15 @@ discard block |
||
1477 | 1475 | |
1478 | 1476 | if (!isset($dir)) $dir = array_pop($selected); |
1479 | 1477 | |
1480 | - switch($action) |
|
1478 | + switch ($action) |
|
1481 | 1479 | { |
1482 | 1480 | case 'upload': |
1483 | 1481 | $script_error = 0; |
1484 | - foreach($selected as $tmp_name => &$data) |
|
1482 | + foreach ($selected as $tmp_name => &$data) |
|
1485 | 1483 | { |
1486 | 1484 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
1487 | 1485 | |
1488 | - if(Vfs::deny_script($path)) |
|
1486 | + if (Vfs::deny_script($path)) |
|
1489 | 1487 | { |
1490 | 1488 | if (!isset($script_error)) |
1491 | 1489 | { |
@@ -1507,7 +1505,7 @@ discard block |
||
1507 | 1505 | { |
1508 | 1506 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
1509 | 1507 | { |
1510 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
1508 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
1511 | 1509 | } |
1512 | 1510 | else |
1513 | 1511 | { |
@@ -1566,16 +1564,16 @@ discard block |
||
1566 | 1564 | case 'link': |
1567 | 1565 | // First upload |
1568 | 1566 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
1569 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
1567 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
1570 | 1568 | |
1571 | - foreach($arr['uploaded'] as $file) |
|
1569 | + foreach ($arr['uploaded'] as $file) |
|
1572 | 1570 | { |
1573 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
1571 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
1574 | 1572 | if (Vfs::file_exists($target) && $app_dir) |
1575 | 1573 | { |
1576 | 1574 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
1577 | 1575 | error_log("Symlinking $target to $app_dir"); |
1578 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
1576 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
1579 | 1577 | } |
1580 | 1578 | } |
1581 | 1579 | // Must return to avoid adding to $response again |
@@ -1597,7 +1595,7 @@ discard block |
||
1597 | 1595 | */ |
1598 | 1596 | private function perms2mode(array $perms) |
1599 | 1597 | { |
1600 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
1598 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
1601 | 1599 | if ($mode['executable']) |
1602 | 1600 | { |
1603 | 1601 | $mode |= 0111; |
@@ -88,7 +88,10 @@ discard block |
||
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 | } |
@@ -266,7 +269,8 @@ discard block |
||
266 | 269 | |
267 | 270 | // This one makes no sense in filemanager |
268 | 271 | unset($actions['share']['children']['shareFilemanager']); |
269 | - if (isset($GLOBALS['egw_info']['user']['apps']['mail'])) { |
|
272 | + if (isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
273 | + { |
|
270 | 274 | $actions['share']['children']['share_mail'] = array( |
271 | 275 | 'caption' => lang('Mail'), |
272 | 276 | 'icon' => 'mail', |
@@ -386,7 +390,10 @@ discard block |
||
386 | 390 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
387 | 391 | $content['nm']['placeholder_actions'] = array('mkdir','paste','share','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink'); |
388 | 392 | |
389 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
393 | + if (isset($_GET['msg'])) |
|
394 | + { |
|
395 | + $msg = $_GET['msg']; |
|
396 | + } |
|
390 | 397 | |
391 | 398 | // Blank favorite set via GET needs special handling for path |
392 | 399 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -420,7 +427,10 @@ discard block |
||
420 | 427 | // reset lettersearch as it confuses users (they think the dir is empty) |
421 | 428 | $content['nm']['searchletter'] = false; |
422 | 429 | // switch recusive display off |
423 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
430 | + if (!$content['nm']['filter']) |
|
431 | + { |
|
432 | + $content['nm']['filter'] = ''; |
|
433 | + } |
|
424 | 434 | } |
425 | 435 | } |
426 | 436 | $view = static::get_view(); |
@@ -469,37 +479,70 @@ discard block |
||
469 | 479 | { |
470 | 480 | $tpl = new Etemplate('filemanager.index'); |
471 | 481 | |
472 | - if($msg) Framework::message($msg); |
|
482 | + if($msg) |
|
483 | + { |
|
484 | + Framework::message($msg); |
|
485 | + } |
|
473 | 486 | |
474 | 487 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
475 | 488 | { |
476 | 489 | if ($content['nm']['action']) |
477 | 490 | { |
478 | 491 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
479 | - if($msg) Framework::message($msg); |
|
492 | + if($msg) |
|
493 | + { |
|
494 | + Framework::message($msg); |
|
495 | + } |
|
480 | 496 | |
481 | 497 | // clean up after action |
482 | 498 | unset($content['nm']['selected']); |
483 | 499 | // 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 |
484 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
485 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
486 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
500 | + if (isset($content['nm']['action'])) |
|
501 | + { |
|
502 | + unset($content['nm']['action']); |
|
503 | + } |
|
504 | + if (isset($content['nm']['nm_action'])) |
|
505 | + { |
|
506 | + unset($content['nm']['nm_action']); |
|
507 | + } |
|
508 | + if (isset($content['nm_action'])) |
|
509 | + { |
|
510 | + unset($content['nm_action']); |
|
511 | + } |
|
487 | 512 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
488 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
513 | + if (isset($content['nm']['rows']['delete'])) |
|
514 | + { |
|
515 | + unset($content['nm']['rows']['delete']); |
|
516 | + } |
|
489 | 517 | } |
490 | 518 | elseif($content['nm']['rows']['delete']) |
491 | 519 | { |
492 | 520 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
493 | - if($msg) Framework::message($msg); |
|
521 | + if($msg) |
|
522 | + { |
|
523 | + Framework::message($msg); |
|
524 | + } |
|
494 | 525 | |
495 | 526 | // clean up after action |
496 | 527 | unset($content['nm']['rows']['delete']); |
497 | 528 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
498 | 529 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
499 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
500 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
501 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
502 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
530 | + if (isset($content['nm']['action'])) |
|
531 | + { |
|
532 | + unset($content['nm']['action']); |
|
533 | + } |
|
534 | + if (isset($content['nm']['nm_action'])) |
|
535 | + { |
|
536 | + unset($content['nm']['nm_action']); |
|
537 | + } |
|
538 | + if (isset($content['nm_action'])) |
|
539 | + { |
|
540 | + unset($content['nm_action']); |
|
541 | + } |
|
542 | + if (isset($content['nm']['selected'])) |
|
543 | + { |
|
544 | + unset($content['nm']['selected']); |
|
545 | + } |
|
503 | 546 | } |
504 | 547 | unset($content['nm']['rows']); |
505 | 548 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -666,9 +709,12 @@ discard block |
||
666 | 709 | foreach(Vfs::find($path) as $p) |
667 | 710 | { |
668 | 711 | $to = $dir.substr($p,$len); |
669 | - if ($to == $p) // cant copy into itself! |
|
712 | + if ($to == $p) |
|
713 | + { |
|
714 | + // cant copy into itself! |
|
670 | 715 | { |
671 | 716 | ++$errs; |
717 | + } |
|
672 | 718 | continue; |
673 | 719 | } |
674 | 720 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -723,7 +769,10 @@ discard block |
||
723 | 769 | continue; |
724 | 770 | } |
725 | 771 | } |
726 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
772 | + if ($target[0] != '/') |
|
773 | + { |
|
774 | + $target = Vfs::concat($dir, $target); |
|
775 | + } |
|
727 | 776 | if (!Vfs::stat($target)) |
728 | 777 | { |
729 | 778 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -766,10 +815,16 @@ discard block |
||
766 | 815 | switch($action) |
767 | 816 | { |
768 | 817 | case 'document': |
769 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
818 | + if (!$settings) |
|
819 | + { |
|
820 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
821 | + } |
|
770 | 822 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
771 | 823 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
772 | - if($msg) return $msg; |
|
824 | + if($msg) |
|
825 | + { |
|
826 | + return $msg; |
|
827 | + } |
|
773 | 828 | $errs = count($selected); |
774 | 829 | return false; |
775 | 830 | } |
@@ -806,7 +861,9 @@ discard block |
||
806 | 861 | unset($selected[$key]); |
807 | 862 | } |
808 | 863 | } |
809 | - if ($selected) // somethings left to delete |
|
864 | + if ($selected) |
|
865 | + { |
|
866 | + // somethings left to delete |
|
810 | 867 | { |
811 | 868 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
812 | 869 | foreach((array)$selected as $path) |
@@ -814,6 +871,7 @@ discard block |
||
814 | 871 | if (Vfs::isProtectedDir($path)) |
815 | 872 | { |
816 | 873 | $errs++; |
874 | + } |
|
817 | 875 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
818 | 876 | } |
819 | 877 | } |
@@ -862,7 +920,10 @@ discard block |
||
862 | 920 | Api\Cache::setSession('filemanager', 'index', |
863 | 921 | array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
864 | 922 | } |
865 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
923 | + if(!$query['path']) |
|
924 | + { |
|
925 | + $query['path'] = static::get_home_dir(); |
|
926 | + } |
|
866 | 927 | |
867 | 928 | // Change template to match selected view |
868 | 929 | if($query['view']) |
@@ -951,10 +1012,16 @@ discard block |
||
951 | 1012 | { |
952 | 1013 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
953 | 1014 | $row =& $rows[$path2n[$path]]; |
954 | - if ( !is_array($props) ) continue; |
|
1015 | + if ( !is_array($props) ) |
|
1016 | + { |
|
1017 | + continue; |
|
1018 | + } |
|
955 | 1019 | foreach($props as $prop) |
956 | 1020 | { |
957 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
1021 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
1022 | + { |
|
1023 | + continue; |
|
1024 | + } |
|
958 | 1025 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
959 | 1026 | } |
960 | 1027 | } |
@@ -1005,7 +1072,10 @@ discard block |
||
1005 | 1072 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
1006 | 1073 | |
1007 | 1074 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
1008 | - if($filter == 5) $maxdepth = 2; |
|
1075 | + if($filter == 5) |
|
1076 | + { |
|
1077 | + $maxdepth = 2; |
|
1078 | + } |
|
1009 | 1079 | $n = 0; |
1010 | 1080 | $vfs_options = array( |
1011 | 1081 | 'mindepth' => 1, |
@@ -1130,7 +1200,10 @@ discard block |
||
1130 | 1200 | if (!($dir = Vfs::dirname($path))) |
1131 | 1201 | { |
1132 | 1202 | $msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false"; |
1133 | - if ($button == 'save') $button = 'apply'; |
|
1203 | + if ($button == 'save') |
|
1204 | + { |
|
1205 | + $button = 'apply'; |
|
1206 | + } |
|
1134 | 1207 | continue; |
1135 | 1208 | } |
1136 | 1209 | $to = Vfs::concat($dir, $content['name']); |
@@ -1139,7 +1212,10 @@ discard block |
||
1139 | 1212 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
1140 | 1213 | lang('To overwrite the existing file store again.',lang($button))); |
1141 | 1214 | $content['confirm_overwrite'] = $to; |
1142 | - if ($button == 'save') $button = 'apply'; |
|
1215 | + if ($button == 'save') |
|
1216 | + { |
|
1217 | + $button = 'apply'; |
|
1218 | + } |
|
1143 | 1219 | continue; |
1144 | 1220 | } |
1145 | 1221 | if (Vfs::rename($path,$to)) |
@@ -1212,13 +1288,19 @@ discard block |
||
1212 | 1288 | } |
1213 | 1289 | if ($ok && !$failed) |
1214 | 1290 | { |
1215 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1291 | + if(!$perm_changed++) |
|
1292 | + { |
|
1293 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1294 | + } |
|
1216 | 1295 | $content['old'][$name] = $content[$name]; |
1217 | 1296 | } |
1218 | 1297 | elseif($failed) |
1219 | 1298 | { |
1220 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1299 | + if(!$perm_failed++) |
|
1300 | + { |
|
1301 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1221 | 1302 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
1303 | + } |
|
1222 | 1304 | } |
1223 | 1305 | } |
1224 | 1306 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1271,7 +1353,10 @@ discard block |
||
1271 | 1353 | } |
1272 | 1354 | } |
1273 | 1355 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
1274 | - if ($button == 'save') Framework::window_close(); |
|
1356 | + if ($button == 'save') |
|
1357 | + { |
|
1358 | + Framework::window_close(); |
|
1359 | + } |
|
1275 | 1360 | } |
1276 | 1361 | if ($content['is_link'] && !Vfs::stat($path)) |
1277 | 1362 | { |
@@ -1281,13 +1366,19 @@ discard block |
||
1281 | 1366 | $content['icon'] = Vfs::mime_icon($content['mime']); |
1282 | 1367 | $content['msg'] = $msg; |
1283 | 1368 | |
1284 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
1369 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
1370 | + { |
|
1371 | + $content['ro_uid_root'] = 'root'; |
|
1372 | + } |
|
1285 | 1373 | // only owner can change group & perms |
1286 | 1374 | if (($readonlys['gid'] = !$content['is_owner'] || |
1287 | 1375 | Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs |
1288 | 1376 | !Vfs::is_writable($path)) |
1289 | 1377 | { |
1290 | - if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
|
1378 | + if (!$content['gid']) |
|
1379 | + { |
|
1380 | + $content['ro_gid_root'] = 'root'; |
|
1381 | + } |
|
1291 | 1382 | foreach($content['perms'] as $name => $value) |
1292 | 1383 | { |
1293 | 1384 | $readonlys['perms['.$name.']'] = true; |
@@ -1322,9 +1413,13 @@ discard block |
||
1322 | 1413 | 0 => lang('No access'), |
1323 | 1414 | ); |
1324 | 1415 | if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl |
1325 | - $GLOBALS['egw_info']['user']['account_id'] == Vfs::$user) // leave eACL tab disabled for sharing |
|
1416 | + $GLOBALS['egw_info']['user']['account_id'] == Vfs::$user) |
|
1417 | + { |
|
1418 | + // leave eACL tab disabled for sharing |
|
1326 | 1419 | { |
1327 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1420 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
1421 | + } |
|
1422 | + // --> switch the tab on again |
|
1328 | 1423 | foreach($content['eacl'] as &$eacl) |
1329 | 1424 | { |
1330 | 1425 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1381,10 +1476,13 @@ discard block |
||
1381 | 1476 | 'comment' => (string)$content['comment'], |
1382 | 1477 | 'mergeapp' => $content['mergeapp'] |
1383 | 1478 | ); |
1384 | - if ($cfs) foreach($cfs as $name => $data) |
|
1479 | + if ($cfs) |
|
1480 | + { |
|
1481 | + foreach($cfs as $name => $data) |
|
1385 | 1482 | { |
1386 | 1483 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1387 | 1484 | } |
1485 | + } |
|
1388 | 1486 | } |
1389 | 1487 | if (Vfs::$is_root) |
1390 | 1488 | { |
@@ -1411,7 +1509,10 @@ discard block |
||
1411 | 1509 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1412 | 1510 | |
1413 | 1511 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
1414 | - if (true) $tabs = array(); |
|
1512 | + if (true) |
|
1513 | + { |
|
1514 | + $tabs = array(); |
|
1515 | + } |
|
1415 | 1516 | |
1416 | 1517 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
1417 | 1518 | { |
@@ -1475,7 +1576,10 @@ discard block |
||
1475 | 1576 | 'files' => 0, |
1476 | 1577 | ); |
1477 | 1578 | |
1478 | - if (!isset($dir)) $dir = array_pop($selected); |
|
1579 | + if (!isset($dir)) |
|
1580 | + { |
|
1581 | + $dir = array_pop($selected); |
|
1582 | + } |
|
1479 | 1583 | |
1480 | 1584 | switch($action) |
1481 | 1585 | { |
@@ -1573,7 +1677,10 @@ discard block |
||
1573 | 1677 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
1574 | 1678 | if (Vfs::file_exists($target) && $app_dir) |
1575 | 1679 | { |
1576 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
1680 | + if (!Vfs::file_exists($app_dir)) |
|
1681 | + { |
|
1682 | + Vfs::mkdir($app_dir); |
|
1683 | + } |
|
1577 | 1684 | error_log("Symlinking $target to $app_dir"); |
1578 | 1685 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
1579 | 1686 | } |
@@ -131,7 +131,10 @@ discard block |
||
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 |
||
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 | { |
@@ -78,14 +78,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |