@@ -464,6 +464,7 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @param string $name |
466 | 466 | * @param string $value =null value to use, default $config[$name] |
467 | + * @return string |
|
467 | 468 | */ |
468 | 469 | function config_translate($name, $value=null) |
469 | 470 | { |
@@ -1194,7 +1195,7 @@ discard block |
||
1194 | 1195 | * Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose) |
1195 | 1196 | * |
1196 | 1197 | * @param string $cmd |
1197 | - * @param array& $output=null $output of command, only if !$verbose !!! |
|
1198 | + * @param array& $output $output of command, only if !$verbose !!! |
|
1198 | 1199 | * @param int|array $no_bailout =null exit code(s) to NOT bail out |
1199 | 1200 | * @return int exit code of $cmd |
1200 | 1201 | */ |
@@ -10,10 +10,13 @@ discard block |
||
10 | 10 | * @version $Id$ |
11 | 11 | */ |
12 | 12 | |
13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
13 | +if (php_sapi_name() !== 'cli') |
|
14 | +{ |
|
15 | + // security precaution: forbit calling setup-cli as web-page |
|
14 | 16 | { |
15 | 17 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
16 | 18 | } |
19 | +} |
|
17 | 20 | date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
18 | 21 | |
19 | 22 | $verbose = 0; |
@@ -137,7 +140,10 @@ discard block |
||
137 | 140 | case 'release': |
138 | 141 | case 'copychangelog': |
139 | 142 | $config[$name] = $value; |
140 | - if ($value) array_unshift($config['run'],$name); |
|
143 | + if ($value) |
|
144 | + { |
|
145 | + array_unshift($config['run'],$name); |
|
146 | + } |
|
141 | 147 | break; |
142 | 148 | |
143 | 149 | case 'editchangelog': |
@@ -153,7 +159,10 @@ discard block |
||
153 | 159 | { |
154 | 160 | usage("Path '$value' not found!"); |
155 | 161 | } |
156 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
162 | + if (!in_array('obs',$config['run'])) |
|
163 | + { |
|
164 | + $config['run'][] = 'obs'; |
|
165 | + } |
|
157 | 166 | // fall through |
158 | 167 | default: |
159 | 168 | $config[$name] = $value; |
@@ -211,7 +220,10 @@ discard block |
||
211 | 220 | } |
212 | 221 | |
213 | 222 | $cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD'); |
214 | - if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd; |
|
223 | + if (getcwd() != $path) |
|
224 | + { |
|
225 | + $cmd = 'cd '.$path.'; '.$cmd; |
|
226 | + } |
|
215 | 227 | $output = null; |
216 | 228 | run_cmd($cmd, $output); |
217 | 229 | |
@@ -242,7 +254,10 @@ discard block |
||
242 | 254 | { |
243 | 255 | global $config, $verbose; |
244 | 256 | |
245 | - if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
257 | + if ($verbose) |
|
258 | + { |
|
259 | + echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
260 | + } |
|
246 | 261 | |
247 | 262 | if (!is_dir($config['checkoutdir'])) |
248 | 263 | { |
@@ -273,12 +288,21 @@ discard block |
||
273 | 288 | elseif (isset($module) && preg_match('/^checkout\s*=\s*(git\s+clone\s+(-b\s+[0-9.]+\s+)?((git|http)[^ ]+)|svn\s+checkout\s+((svn|http)[^ ]+))/', $line, $matches)) |
274 | 289 | { |
275 | 290 | $repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[5] : $matches[3]; |
276 | - if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
291 | + if (substr($matches[1], 0, 3) == 'svn') |
|
292 | + { |
|
293 | + $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
294 | + } |
|
277 | 295 | $modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url; |
278 | - if ($module === '' && !isset($baseurl)) $baseurl = str_replace('/egroupware.git', '', $url); |
|
296 | + if ($module === '' && !isset($baseurl)) |
|
297 | + { |
|
298 | + $baseurl = str_replace('/egroupware.git', '', $url); |
|
299 | + } |
|
279 | 300 | } |
280 | 301 | } |
281 | - if ($verbose) print_r($modules); |
|
302 | + if ($verbose) |
|
303 | + { |
|
304 | + print_r($modules); |
|
305 | + } |
|
282 | 306 | return $modules; |
283 | 307 | } |
284 | 308 | |
@@ -345,7 +369,11 @@ discard block |
||
345 | 369 | |
346 | 370 | $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
347 | 371 | |
348 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
372 | + if (empty($config['tag'])) |
|
373 | + { |
|
374 | + return; |
|
375 | + } |
|
376 | + // otherwise we copy everything in svn root! |
|
349 | 377 | |
350 | 378 | echo "Creating tag $config[tag]\n"; |
351 | 379 | |
@@ -361,7 +389,10 @@ discard block |
||
361 | 389 | global $config,$verbose; |
362 | 390 | |
363 | 391 | // push local changes to Github incl. tags |
364 | - if ($verbose) echo "Pushing changes and tags\n"; |
|
392 | + if ($verbose) |
|
393 | + { |
|
394 | + echo "Pushing changes and tags\n"; |
|
395 | + } |
|
365 | 396 | chdir($config['checkoutdir']); |
366 | 397 | run_cmd($config['mr']. ' up'); // in case someone else pushed something |
367 | 398 | chdir($config['checkoutdir']); |
@@ -429,7 +460,10 @@ discard block |
||
429 | 460 | { |
430 | 461 | continue; |
431 | 462 | } |
432 | - if ($verbose) echo "Uploading $path as $content_type\n"; |
|
463 | + if ($verbose) |
|
464 | + { |
|
465 | + echo "Uploading $path as $content_type\n"; |
|
466 | + } |
|
433 | 467 | $name = basename($path); |
434 | 468 | github_api($config['upload_url'], array( |
435 | 469 | 'name' => $name, |
@@ -441,7 +475,10 @@ discard block |
||
441 | 475 | { |
442 | 476 | $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
443 | 477 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
444 | - if ($verbose) echo $cmd."\n"; |
|
478 | + if ($verbose) |
|
479 | + { |
|
480 | + echo $cmd."\n"; |
|
481 | + } |
|
445 | 482 | passthru($cmd); |
446 | 483 | } |
447 | 484 | } |
@@ -474,25 +511,40 @@ discard block |
||
474 | 511 | { |
475 | 512 | case 'POST': |
476 | 513 | curl_setopt($c, CURLOPT_POST, true); |
477 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
514 | + if (is_array($data)) |
|
515 | + { |
|
516 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
517 | + } |
|
478 | 518 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
479 | 519 | break; |
480 | 520 | case 'GET': |
481 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
521 | + if(count($data)) |
|
522 | + { |
|
523 | + $url .= '?' . http_build_query($data); |
|
524 | + } |
|
482 | 525 | break; |
483 | 526 | case 'FILE': |
484 | 527 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
485 | 528 | curl_setopt($c, CURLOPT_POST, true); |
486 | 529 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
487 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
530 | + if(count($data)) |
|
531 | + { |
|
532 | + $url .= '?' . http_build_query($data); |
|
533 | + } |
|
488 | 534 | break; |
489 | 535 | default: |
490 | 536 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
491 | 537 | } |
492 | 538 | curl_setopt($c, CURLOPT_URL, $url); |
493 | 539 | |
494 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
495 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
540 | + if (is_string($data)) |
|
541 | + { |
|
542 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
543 | + } |
|
544 | + if ($verbose) |
|
545 | + { |
|
546 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
547 | + } |
|
496 | 548 | |
497 | 549 | if (($response = curl_exec($c)) === false) |
498 | 550 | { |
@@ -503,7 +555,10 @@ discard block |
||
503 | 555 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
504 | 556 | } |
505 | 557 | |
506 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
558 | + if ($verbose) |
|
559 | + { |
|
560 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
561 | + } |
|
507 | 562 | |
508 | 563 | curl_close($c); |
509 | 564 | |
@@ -520,13 +575,19 @@ discard block |
||
520 | 575 | { |
521 | 576 | global $config; |
522 | 577 | |
523 | - if (!isset($value)) $value = $config[$name]; |
|
578 | + if (!isset($value)) |
|
579 | + { |
|
580 | + $value = $config[$name]; |
|
581 | + } |
|
524 | 582 | if (is_string($value) && strpos($value, '$') !== false) |
525 | 583 | { |
526 | 584 | $translate = array(); |
527 | 585 | foreach($config as $n => $val) |
528 | 586 | { |
529 | - if (is_string($val)) $translate['$'.$n] = $val; |
|
587 | + if (is_string($val)) |
|
588 | + { |
|
589 | + $translate['$'.$n] = $val; |
|
590 | + } |
|
530 | 591 | } |
531 | 592 | $value = strtr($value, $translate); |
532 | 593 | } |
@@ -628,7 +689,10 @@ discard block |
||
628 | 689 | if (is_null($revision)) |
629 | 690 | { |
630 | 691 | list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
631 | - if (empty($branch)) $branch = $config['version']; |
|
692 | + if (empty($branch)) |
|
693 | + { |
|
694 | + $branch = $config['version']; |
|
695 | + } |
|
632 | 696 | $tags_url .= '/tags'; |
633 | 697 | $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
634 | 698 | $matches = null; |
@@ -654,11 +718,18 @@ discard block |
||
654 | 718 | $message = ''; |
655 | 719 | foreach($xml as $log) |
656 | 720 | { |
657 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
721 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) |
|
722 | + { |
|
723 | + continue; |
|
724 | + } |
|
725 | + // no match --> ignore |
|
658 | 726 | |
659 | 727 | $message .= $msg."\n"; |
660 | 728 | } |
661 | - if ($verbose) echo $message; |
|
729 | + if ($verbose) |
|
730 | + { |
|
731 | + echo $message; |
|
732 | + } |
|
662 | 733 | |
663 | 734 | return $message; |
664 | 735 | } |
@@ -689,7 +760,10 @@ discard block |
||
689 | 760 | { |
690 | 761 | return null; |
691 | 762 | } |
692 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
763 | + if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) |
|
764 | + { |
|
765 | + $msg = $prefix.$msg; |
|
766 | + } |
|
693 | 767 | |
694 | 768 | return $msg; |
695 | 769 | } |
@@ -726,7 +800,10 @@ discard block |
||
726 | 800 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
727 | 801 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
728 | 802 | { |
729 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
803 | + if ($verbose) |
|
804 | + { |
|
805 | + echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
806 | + } |
|
730 | 807 | return (int)$log['revision']; |
731 | 808 | } |
732 | 809 | } |
@@ -746,7 +823,10 @@ discard block |
||
746 | 823 | { |
747 | 824 | usage("Path '$config[obs]' not found!"); |
748 | 825 | } |
749 | - if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
826 | + if ($verbose) |
|
827 | + { |
|
828 | + echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
829 | + } |
|
750 | 830 | run_cmd('osc up '.$config['obs']); |
751 | 831 | |
752 | 832 | $n = 0; |
@@ -766,10 +846,16 @@ discard block |
||
766 | 846 | if (basename($path) != basename($new_name)) |
767 | 847 | { |
768 | 848 | unlink($path); |
769 | - if ($verbose) echo "rm $path\n"; |
|
849 | + if ($verbose) |
|
850 | + { |
|
851 | + echo "rm $path\n"; |
|
852 | + } |
|
770 | 853 | } |
771 | 854 | copy($new_name,dirname($path).'/'.basename($new_name)); |
772 | - if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
|
855 | + if ($verbose) |
|
856 | + { |
|
857 | + echo "cp $new_name ".dirname($path)."/\n"; |
|
858 | + } |
|
773 | 859 | ++$n; |
774 | 860 | } |
775 | 861 | // if we have no changelog (eg. because commands run separate), try parsing it from changelog file |
@@ -807,7 +893,10 @@ discard block |
||
807 | 893 | if ($content != $content_was) |
808 | 894 | { |
809 | 895 | file_put_contents($path,$content); |
810 | - if ($verbose) echo "Updated $path\n"; |
|
896 | + if ($verbose) |
|
897 | + { |
|
898 | + echo "Updated $path\n"; |
|
899 | + } |
|
811 | 900 | ++$n; |
812 | 901 | } |
813 | 902 | } |
@@ -845,9 +934,12 @@ discard block |
||
845 | 934 | } |
846 | 935 | $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
847 | 936 | $logentry = ''; |
848 | - while($lines[$n]) // entry is terminated by empty line |
|
937 | + while($lines[$n]) |
|
938 | + { |
|
939 | + // entry is terminated by empty line |
|
849 | 940 | { |
850 | 941 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
942 | + } |
|
851 | 943 | ++$n; |
852 | 944 | } |
853 | 945 | return substr($logentry, 0, -1); // remove training "\n" |
@@ -868,7 +960,10 @@ discard block |
||
868 | 960 | |
869 | 961 | list($header) = explode("\n", $content); |
870 | 962 | $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
871 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
963 | + if (substr($config['changelog'],0,2) != ' ') |
|
964 | + { |
|
965 | + $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
966 | + } |
|
872 | 967 | $content = $new_header."\n\n".$config['changelog']. |
873 | 968 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
874 | 969 | |
@@ -882,10 +977,13 @@ discard block |
||
882 | 977 | { |
883 | 978 | global $config; |
884 | 979 | |
885 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
980 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
981 | + { |
|
982 | + // sha1_file cant deal with '~/rpm' |
|
886 | 983 | { |
887 | 984 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
888 | 985 | } |
986 | + } |
|
889 | 987 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
890 | 988 | |
891 | 989 | if (!file_exists($sumsfile)) |
@@ -896,11 +994,17 @@ discard block |
||
896 | 994 | // signing it |
897 | 995 | if (empty($config['gpg']) || !file_exists($config['gpg'])) |
898 | 996 | { |
899 | - if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
997 | + if (!empty($config['gpg'])) |
|
998 | + { |
|
999 | + echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
1000 | + } |
|
900 | 1001 | return; |
901 | 1002 | } |
902 | 1003 | echo "Signing sha1sum file:\n"; |
903 | - if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
|
1004 | + if (file_exists($sumsfile.'.asc')) |
|
1005 | + { |
|
1006 | + unlink($sumsfile.'.asc'); |
|
1007 | + } |
|
904 | 1008 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
905 | 1009 | run_cmd($cmd); |
906 | 1010 | unlink($sumsfile); // delete the unsigned file |
@@ -913,11 +1017,17 @@ discard block |
||
913 | 1017 | { |
914 | 1018 | global $config; |
915 | 1019 | |
916 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
917 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
1020 | + if (!file_exists($config['sourcedir'])) |
|
1021 | + { |
|
1022 | + mkdir($config['sourcedir'],0755,true); |
|
1023 | + } |
|
1024 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
1025 | + { |
|
1026 | + // sha1_file cant deal with '~/rpm' |
|
918 | 1027 | { |
919 | 1028 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
920 | 1029 | } |
1030 | + } |
|
921 | 1031 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
922 | 1032 | $sums = ''; |
923 | 1033 | |
@@ -955,12 +1065,22 @@ discard block |
||
955 | 1065 | { |
956 | 1066 | foreach((array)$config['all-add'] as $add) |
957 | 1067 | { |
958 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
959 | - if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
|
1068 | + if (substr($add, -4) != '.tar') |
|
1069 | + { |
|
1070 | + continue; |
|
1071 | + } |
|
1072 | + // probably a module |
|
1073 | + if (!($tar = realpath($add))) |
|
1074 | + { |
|
1075 | + throw new Exception("File '$add' not found!"); |
|
1076 | + } |
|
960 | 1077 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
961 | 1078 | } |
962 | 1079 | } |
963 | - if (file_exists($file.'.bz2')) $cmd .= '; rm -f '.$file.'.bz2'; |
|
1080 | + if (file_exists($file.'.bz2')) |
|
1081 | + { |
|
1082 | + $cmd .= '; rm -f '.$file.'.bz2'; |
|
1083 | + } |
|
964 | 1084 | $cmd .= '; '.$config['bzip2'].' '.$file; |
965 | 1085 | // run cmd now and continue without adding all tar-ball to sums, as we dont want to publish it |
966 | 1086 | run_cmd($cmd); |
@@ -981,7 +1101,10 @@ discard block |
||
981 | 1101 | |
982 | 1102 | foreach($config['extra'] as $name => $modules) |
983 | 1103 | { |
984 | - if (is_numeric($name)) $name = $modules; |
|
1104 | + if (is_numeric($name)) |
|
1105 | + { |
|
1106 | + $name = $modules; |
|
1107 | + } |
|
985 | 1108 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
986 | 1109 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
987 | 1110 | switch($type) |
@@ -1022,7 +1145,10 @@ discard block |
||
1022 | 1145 | { |
1023 | 1146 | echo "Updating virus signatures\n"; |
1024 | 1147 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
1025 | - if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
|
1148 | + if (!$verbose && function_exists('posix_getuid') && posix_getuid()) |
|
1149 | + { |
|
1150 | + echo $cmd."\n"; |
|
1151 | + } |
|
1026 | 1152 | $output = null; |
1027 | 1153 | run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
1028 | 1154 | } |
@@ -1050,7 +1176,10 @@ discard block |
||
1050 | 1176 | } |
1051 | 1177 | |
1052 | 1178 | // we need to stash uncommited changes like .mrconfig, before copying |
1053 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash"); |
|
1179 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
1180 | + { |
|
1181 | + run_cmd("cd $config[checkoutdir]; git stash"); |
|
1182 | + } |
|
1054 | 1183 | |
1055 | 1184 | try { |
1056 | 1185 | $cmd = '/usr/bin/rsync -r --delete --delete-excluded --exclude .svn --exclude .git\* --exclude .mrconfig --exclude node_modules/ '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/'; |
@@ -1059,8 +1188,14 @@ discard block |
||
1059 | 1188 | catch (Exception $e) { |
1060 | 1189 | // catch failures to pop stash, before throwing exception |
1061 | 1190 | } |
1062 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop"); |
|
1063 | - if (isset($e)) throw $e; |
|
1191 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
1192 | + { |
|
1193 | + run_cmd("git stash pop"); |
|
1194 | + } |
|
1195 | + if (isset($e)) |
|
1196 | + { |
|
1197 | + throw $e; |
|
1198 | + } |
|
1064 | 1199 | |
1065 | 1200 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
1066 | 1201 | { |
@@ -1145,9 +1280,12 @@ discard block |
||
1145 | 1280 | if ($ret || substr($line,0,5) == 'URL: ') |
1146 | 1281 | { |
1147 | 1282 | $url = substr($line,5); |
1148 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
1283 | + if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) |
|
1284 | + { |
|
1285 | + // wrong branch (or no svn dir) |
|
1149 | 1286 | { |
1150 | 1287 | echo "Checkout is of wrong branch --> deleting it\n"; |
1288 | + } |
|
1151 | 1289 | system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
1152 | 1290 | clearstatcache(); |
1153 | 1291 | } |
@@ -1194,19 +1332,31 @@ discard block |
||
1194 | 1332 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
1195 | 1333 | $url = $svnbranch.'/'.$config['svnalias']; |
1196 | 1334 | $cmd = $svn.' propget svn:externals --strict '.$url; |
1197 | - if ($verbose) echo $cmd."\n"; |
|
1335 | + if ($verbose) |
|
1336 | + { |
|
1337 | + echo $cmd."\n"; |
|
1338 | + } |
|
1198 | 1339 | $output = $ret = null; |
1199 | 1340 | exec($cmd,$output,$ret); |
1200 | 1341 | $config['modules'] = array(); |
1201 | 1342 | foreach($output as $line) |
1202 | 1343 | { |
1203 | 1344 | $line = trim($line); |
1204 | - if (empty($line) || $line[0] == '#') continue; |
|
1345 | + if (empty($line) || $line[0] == '#') |
|
1346 | + { |
|
1347 | + continue; |
|
1348 | + } |
|
1205 | 1349 | list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
1206 | 1350 | $matches = null; |
1207 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1351 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
1352 | + { |
|
1353 | + die("Invalid SVN URL: $url\n"); |
|
1354 | + } |
|
1208 | 1355 | $repo = $matches[1]; |
1209 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1356 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
1357 | + { |
|
1358 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1359 | + } |
|
1210 | 1360 | $config['modules'][$repo][$path] = $url; |
1211 | 1361 | } |
1212 | 1362 | // process extra modules |
@@ -1215,13 +1365,25 @@ discard block |
||
1215 | 1365 | $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
1216 | 1366 | $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
1217 | 1367 | $url .= $module; |
1218 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
1219 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1368 | + if (strpos($module,'://') !== false) |
|
1369 | + { |
|
1370 | + $module = basename($module); |
|
1371 | + } |
|
1372 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
1373 | + { |
|
1374 | + die("Invalid SVN URL: $url\n"); |
|
1375 | + } |
|
1220 | 1376 | $repo = $matches[1]; |
1221 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1377 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
1378 | + { |
|
1379 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1380 | + } |
|
1222 | 1381 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
1223 | 1382 | } |
1224 | - if ($verbose) print_r($config['modules']); |
|
1383 | + if ($verbose) |
|
1384 | + { |
|
1385 | + print_r($config['modules']); |
|
1386 | + } |
|
1225 | 1387 | return $config['modules']; |
1226 | 1388 | } |
1227 | 1389 | |
@@ -1232,7 +1394,11 @@ discard block |
||
1232 | 1394 | { |
1233 | 1395 | global $config,$svn; |
1234 | 1396 | |
1235 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
1397 | + if (empty($config['svntag'])) |
|
1398 | + { |
|
1399 | + return; |
|
1400 | + } |
|
1401 | + // otherwise we copy everything in svn root! |
|
1236 | 1402 | |
1237 | 1403 | $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
1238 | 1404 | |
@@ -1271,11 +1437,17 @@ discard block |
||
1271 | 1437 | { |
1272 | 1438 | $output[] = $cmd; |
1273 | 1439 | exec($cmd,$output,$ret); |
1274 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
1440 | + if ($verbose) |
|
1441 | + { |
|
1442 | + echo implode("\n",$output)."\n"; |
|
1443 | + } |
|
1275 | 1444 | } |
1276 | 1445 | if ($ret && !in_array($ret,(array)$no_bailout)) |
1277 | 1446 | { |
1278 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
1447 | + if (!$verbose) |
|
1448 | + { |
|
1449 | + echo implode("\n",$output)."\n"; |
|
1450 | + } |
|
1279 | 1451 | throw new Exception("Error during '$cmd' --> aborting",$ret); |
1280 | 1452 | } |
1281 | 1453 | return $ret; |
@@ -1321,7 +1493,10 @@ discard block |
||
1321 | 1493 | echo "options and their defaults:\n"; |
1322 | 1494 | if ($verbose) |
1323 | 1495 | { |
1324 | - if (!isset($config['modules'])) $config['modules'] = get_modules_per_repo(); |
|
1496 | + if (!isset($config['modules'])) |
|
1497 | + { |
|
1498 | + $config['modules'] = get_modules_per_repo(); |
|
1499 | + } |
|
1325 | 1500 | } |
1326 | 1501 | else |
1327 | 1502 | { |
@@ -1329,7 +1504,10 @@ discard block |
||
1329 | 1504 | } |
1330 | 1505 | foreach($config as $name => $default) |
1331 | 1506 | { |
1332 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
1507 | + if (is_array($default)) |
|
1508 | + { |
|
1509 | + $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
1510 | + } |
|
1333 | 1511 | echo '--'.str_pad($name,20).$default."\n"; |
1334 | 1512 | } |
1335 | 1513 | if ($error) |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | } |
404 | 404 | |
405 | 405 | $archives = config_translate('upload'); |
406 | - echo "Uploading $archives to $config[upload_url]\n"; |
|
406 | + echo "uploading $archives to $config[upload_url]\n"; |
|
407 | 407 | |
408 | 408 | foreach(glob($archives, GLOB_BRACE) as $path) |
409 | 409 | { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | { |
430 | 430 | continue; |
431 | 431 | } |
432 | - if ($verbose) echo "Uploading $path as $content_type\n"; |
|
432 | + if ($verbose) echo "uploading $path as $content_type\n"; |
|
433 | 433 | $name = basename($path); |
434 | 434 | github_api($config['upload_url'], array( |
435 | 435 | 'name' => $name, |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | curl_setopt($c, CURLOPT_URL, $url); |
493 | 493 | |
494 | 494 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
495 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
495 | + if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
496 | 496 | |
497 | 497 | if (($response = curl_exec($c)) === false) |
498 | 498 | { |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
727 | 727 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
728 | 728 | { |
729 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
729 | + if ($verbose) echo "revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
730 | 730 | return (int)$log['revision']; |
731 | 731 | } |
732 | 732 | } |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | if ($content != $content_was) |
808 | 808 | { |
809 | 809 | file_put_contents($path,$content); |
810 | - if ($verbose) echo "Updated $path\n"; |
|
810 | + if ($verbose) echo "updated $path\n"; |
|
811 | 811 | ++$n; |
812 | 812 | } |
813 | 813 | } |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | } |
943 | 943 | foreach($config['types'] as $type) |
944 | 944 | { |
945 | - echo "Creating $type archives\n"; |
|
945 | + echo "creating $type archives\n"; |
|
946 | 946 | $tar_type = $type == 'tar.bz2' ? 'j' : 'z'; |
947 | 947 | |
948 | 948 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
1066 | 1066 | { |
1067 | - echo "Running $cmd\n"; |
|
1067 | + echo "running $cmd\n"; |
|
1068 | 1068 | run_cmd($cmd); |
1069 | 1069 | } |
1070 | 1070 | // fix permissions |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | { |
15 | 15 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
16 | 16 | } |
17 | -date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
|
17 | +date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
|
18 | 18 | |
19 | 19 | $verbose = 0; |
20 | 20 | $config = array( |
21 | 21 | 'packagename' => 'egroupware-epl', |
22 | - 'version' => '16.1', // '14.3' |
|
22 | + 'version' => '16.1', // '14.3' |
|
23 | 23 | 'packaging' => date('Ymd'), // '20160520' |
24 | - 'branch' => 'master', // checked out branch |
|
25 | - 'tag' => '$version.$packaging', // name of tag |
|
24 | + 'branch' => 'master', // checked out branch |
|
25 | + 'tag' => '$version.$packaging', // name of tag |
|
26 | 26 | 'checkoutdir' => realpath(__DIR__.'/../..'), |
27 | 27 | 'egw_buildroot' => '/tmp/build_root/epl_16.1_buildroot', |
28 | 28 | 'sourcedir' => '/home/download/stylite-epl/egroupware-epl-16.1', |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | 'svnalias' => 'aliases/default-ssh', // default alias |
35 | 35 | 'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'), |
36 | 36 | */ |
37 | - 'extra' => array('stylite', 'esyncpro', 'archive', // create an extra archive for given apps |
|
37 | + 'extra' => array('stylite', 'esyncpro', 'archive', // create an extra archive for given apps |
|
38 | 38 | // these apps are placed in egroupware-epl-contrib archive |
39 | 39 | 'contrib' => array('phpgwapi', 'etemplate', 'jdots', 'phpbrain', 'wiki', 'sambaadmin', 'sitemgr', 'phpfreechat')), |
40 | - 'aliasdir' => 'egroupware', // directory created by the alias |
|
41 | - 'types' => array('tar.bz2','tar.gz','zip','all.tar.bz2'), |
|
40 | + 'aliasdir' => 'egroupware', // directory created by the alias |
|
41 | + 'types' => array('tar.bz2', 'tar.gz', 'zip', 'all.tar.bz2'), |
|
42 | 42 | // add given extra-apps or (uncompressed!) archives to above all.tar.bz2 archive |
43 | 43 | 'all-add' => array('contrib', '/home/stylite/epl-trunk/phpfreechat_data_public.tar'), |
44 | 44 | // diverse binaries we need |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | 'gpg' => trim(`which gpg`), |
56 | 56 | 'editor' => trim(`which vi`), |
57 | 57 | 'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"', |
58 | - 'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs --no-dev' : '', |
|
58 | + 'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs --no-dev' : '', |
|
59 | 59 | 'after-checkout' => 'rm -rf */source */templates/*/source', |
60 | 60 | 'packager' => '[email protected]', |
61 | 61 | 'obs' => '/home/stylite/obs/stylite-epl-trunk', |
62 | - 'obs_package_alias' => '', // name used in obs package, if different from packagename |
|
63 | - 'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes |
|
62 | + 'obs_package_alias' => '', // name used in obs package, if different from packagename |
|
63 | + 'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes |
|
64 | 64 | 'changelog_packager' => 'Ralf Becker <[email protected]>', |
65 | 65 | 'editchangelog' => '* ', |
66 | 66 | //'sfuser' => 'ralfbecker', |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | 'upload' => '$sourcedir/*egroupware-epl{,-contrib}-$version.$packaging*', |
70 | 70 | 'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README', |
71 | 71 | 'skip' => array(), |
72 | - 'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'), |
|
72 | + 'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'), |
|
73 | 73 | 'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"', |
74 | - 'github_user' => 'ralfbecker', // Github user for following token |
|
75 | - 'github_token' => '', // Github repo personal access token from above user |
|
74 | + 'github_user' => 'ralfbecker', // Github user for following token |
|
75 | + 'github_token' => '', // Github repo personal access token from above user |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | // process config from command line |
79 | 79 | $argv = $_SERVER['argv']; |
80 | 80 | $prog = array_shift($argv); |
81 | 81 | |
82 | -while(($arg = array_shift($argv))) |
|
82 | +while (($arg = array_shift($argv))) |
|
83 | 83 | { |
84 | 84 | if ($arg == '-v' || $arg == '--verbose') |
85 | 85 | { |
86 | 86 | ++$verbose; |
87 | 87 | } |
88 | - elseif($arg == '-h' || $arg == '--help') |
|
88 | + elseif ($arg == '-h' || $arg == '--help') |
|
89 | 89 | { |
90 | 90 | if (in_array('editchangelog', $config['skip']) || !in_array('editchangelog', $config['run'])) |
91 | 91 | { |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | } |
94 | 94 | usage(); |
95 | 95 | } |
96 | - elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)])) |
|
96 | + elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)])) |
|
97 | 97 | { |
98 | 98 | $value = array_shift($argv); |
99 | - switch($name) |
|
99 | + switch ($name) |
|
100 | 100 | { |
101 | 101 | case 'extra': // stored as array and allow to add/delete items with +/- prefix |
102 | 102 | case 'types': |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | $value = array_unique(preg_split('/[ ,]+/', $value)); |
121 | 121 | } |
122 | - switch($op) |
|
122 | + switch ($op) |
|
123 | 123 | { |
124 | 124 | case '+': |
125 | 125 | $config[$name] = array_unique(array_merge($config[$name], $value)); |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | case 'release': |
138 | 138 | case 'copychangelog': |
139 | 139 | $config[$name] = $value; |
140 | - if ($value) array_unshift($config['run'],$name); |
|
140 | + if ($value) array_unshift($config['run'], $name); |
|
141 | 141 | break; |
142 | 142 | |
143 | 143 | case 'editchangelog': |
144 | 144 | $config[$name] = $value ? $value : true; |
145 | - if (!in_array('editchangelog',$config['run'])) |
|
145 | + if (!in_array('editchangelog', $config['run'])) |
|
146 | 146 | { |
147 | - array_unshift($config['run'],'editchangelog'); |
|
147 | + array_unshift($config['run'], 'editchangelog'); |
|
148 | 148 | } |
149 | 149 | break; |
150 | 150 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | { |
154 | 154 | usage("Path '$value' not found!"); |
155 | 155 | } |
156 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
156 | + if (!in_array('obs', $config['run'])) $config['run'][] = 'obs'; |
|
157 | 157 | // fall through |
158 | 158 | default: |
159 | 159 | $config[$name] = $value; |
@@ -171,16 +171,16 @@ discard block |
||
171 | 171 | } |
172 | 172 | $svn = $config['svn']; |
173 | 173 | |
174 | -$run = array_diff($config['run'],$config['skip']); |
|
174 | +$run = array_diff($config['run'], $config['skip']); |
|
175 | 175 | |
176 | 176 | // if we dont edit the changelog, set packaging from changelog |
177 | 177 | if (!in_array('editchangelog', $run)) |
178 | 178 | { |
179 | 179 | parse_current_changelog(true); |
180 | 180 | } |
181 | -foreach($run as $func) |
|
181 | +foreach ($run as $func) |
|
182 | 182 | { |
183 | - chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir |
|
183 | + chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir |
|
184 | 184 | call_user_func('do_'.$func); |
185 | 185 | } |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages |
196 | 196 | * @return string with changelog |
197 | 197 | */ |
198 | -function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ') |
|
198 | +function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ') |
|
199 | 199 | { |
200 | 200 | //echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n"; |
201 | 201 | global $config; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | run_cmd($cmd, $output); |
217 | 217 | |
218 | 218 | $changelog = ''; |
219 | - foreach($output as $line) |
|
219 | + foreach ($output as $line) |
|
220 | 220 | { |
221 | 221 | if (substr($line, 0, 4) == " " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix))) |
222 | 222 | { |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | { |
249 | 249 | throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!"); |
250 | 250 | } |
251 | - if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig'))) |
|
251 | + if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig'))) |
|
252 | 252 | { |
253 | 253 | throw new Exception("$path not found!"); |
254 | 254 | } |
255 | 255 | $module = $baseurl = null; |
256 | 256 | $modules = array(); |
257 | - foreach(explode("\n", $mrconfig) as $line) |
|
257 | + foreach (explode("\n", $mrconfig) as $line) |
|
258 | 258 | { |
259 | 259 | $matches = null; |
260 | 260 | if (isset($baseurl)) |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : ''). |
320 | 320 | ' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir']; |
321 | 321 | run_cmd($cmd); |
322 | - run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!) |
|
322 | + run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!) |
|
323 | 323 | } |
324 | 324 | elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir'])) |
325 | 325 | { |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | } |
344 | 344 | chdir($config['checkoutdir']); |
345 | 345 | |
346 | - $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
|
346 | + $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
|
347 | 347 | |
348 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
348 | + if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
349 | 349 | |
350 | 350 | echo "Creating tag $config[tag]\n"; |
351 | 351 | |
@@ -358,16 +358,16 @@ discard block |
||
358 | 358 | */ |
359 | 359 | function do_release() |
360 | 360 | { |
361 | - global $config,$verbose; |
|
361 | + global $config, $verbose; |
|
362 | 362 | |
363 | 363 | // push local changes to Github incl. tags |
364 | 364 | if ($verbose) echo "Pushing changes and tags\n"; |
365 | 365 | chdir($config['checkoutdir']); |
366 | - run_cmd($config['mr']. ' up'); // in case someone else pushed something |
|
366 | + run_cmd($config['mr'].' up'); // in case someone else pushed something |
|
367 | 367 | chdir($config['checkoutdir']); |
368 | - run_cmd($config['git'].' push'); // regular commits like changelog |
|
368 | + run_cmd($config['git'].' push'); // regular commits like changelog |
|
369 | 369 | $tag = config_translate('tag'); |
370 | - run_cmd($config['mr']. ' push origin '.$tag); // pushing tags in all apps |
|
370 | + run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps |
|
371 | 371 | |
372 | 372 | if (empty($config['github_user']) || empty($config['github_token'])) |
373 | 373 | { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | 'body' => $config['changelog'], |
385 | 385 | ); |
386 | 386 | $response = github_api("/repos/EGroupware/egroupware/releases", $data); |
387 | - $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template |
|
387 | + $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template |
|
388 | 388 | |
389 | 389 | do_upload(); |
390 | 390 | } |
@@ -394,33 +394,33 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function do_upload() |
396 | 396 | { |
397 | - global $config,$verbose; |
|
397 | + global $config, $verbose; |
|
398 | 398 | |
399 | 399 | if (empty($config['upload_url'])) |
400 | 400 | { |
401 | 401 | $response = github_api("/repos/EGroupware/egroupware/releases", array(), 'GET'); |
402 | - $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response[0]['upload_url']); // remove {?name,label} template |
|
402 | + $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response[0]['upload_url']); // remove {?name,label} template |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | $archives = config_translate('upload'); |
406 | 406 | echo "Uploading $archives to $config[upload_url]\n"; |
407 | 407 | |
408 | - foreach(glob($archives, GLOB_BRACE) as $path) |
|
408 | + foreach (glob($archives, GLOB_BRACE) as $path) |
|
409 | 409 | { |
410 | 410 | $label = null; |
411 | 411 | if (substr($path, -4) == '.zip') |
412 | 412 | { |
413 | 413 | $content_type = 'application/zip'; |
414 | 414 | } |
415 | - elseif(substr($path, -7) == '.tar.gz') |
|
415 | + elseif (substr($path, -7) == '.tar.gz') |
|
416 | 416 | { |
417 | 417 | $content_type = 'application/x-gzip'; |
418 | 418 | } |
419 | - elseif(substr($path, -8) == '.tar.bz2') |
|
419 | + elseif (substr($path, -8) == '.tar.bz2') |
|
420 | 420 | { |
421 | 421 | $content_type = 'application/x-bzip2'; |
422 | 422 | } |
423 | - elseif(substr($path, -8) == '.txt.asc') |
|
423 | + elseif (substr($path, -8) == '.txt.asc') |
|
424 | 424 | { |
425 | 425 | $content_type = 'text/plain'; |
426 | 426 | $label = 'Signed hashes of downloads'; |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | |
440 | 440 | if (!empty($config['release'])) |
441 | 441 | { |
442 | - $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
|
442 | + $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
|
443 | 443 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
444 | 444 | if ($verbose) echo $cmd."\n"; |
445 | 445 | passthru($cmd); |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @throws Exception |
458 | 458 | * @return array with response |
459 | 459 | */ |
460 | -function github_api($_url, $data, $method='POST', $upload=null, $content_type=null) |
|
460 | +function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null) |
|
461 | 461 | { |
462 | 462 | global $config, $verbose; |
463 | 463 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | curl_setopt($c, CURLOPT_TIMEOUT, 240); |
471 | 471 | curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); |
472 | 472 | |
473 | - switch($method) |
|
473 | + switch ($method) |
|
474 | 474 | { |
475 | 475 | case 'POST': |
476 | 476 | curl_setopt($c, CURLOPT_POST, true); |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
479 | 479 | break; |
480 | 480 | case 'GET': |
481 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
481 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
482 | 482 | break; |
483 | 483 | case 'FILE': |
484 | 484 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
485 | 485 | curl_setopt($c, CURLOPT_POST, true); |
486 | 486 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
487 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
487 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
488 | 488 | break; |
489 | 489 | default: |
490 | 490 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | curl_setopt($c, CURLOPT_URL, $url); |
493 | 493 | |
494 | 494 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
495 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
495 | + if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n"; |
|
496 | 496 | |
497 | 497 | if (($response = curl_exec($c)) === false) |
498 | 498 | { |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | curl_setopt($c, CURLOPT_HEADER, true); |
501 | 501 | curl_setopt($c, CURLOPT_RETURNTRANSFER, false); |
502 | 502 | curl_exec($c); |
503 | - throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
|
503 | + throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : '')); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @param string $name |
517 | 517 | * @param string $value =null value to use, default $config[$name] |
518 | 518 | */ |
519 | -function config_translate($name, $value=null) |
|
519 | +function config_translate($name, $value = null) |
|
520 | 520 | { |
521 | 521 | global $config; |
522 | 522 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | if (is_string($value) && strpos($value, '$') !== false) |
525 | 525 | { |
526 | 526 | $translate = array(); |
527 | - foreach($config as $n => $val) |
|
527 | + foreach ($config as $n => $val) |
|
528 | 528 | { |
529 | 529 | if (is_string($val)) $translate['$'.$n] = $val; |
530 | 530 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | */ |
551 | 551 | function do_editchangelog() |
552 | 552 | { |
553 | - global $config,$svn; |
|
553 | + global $config, $svn; |
|
554 | 554 | |
555 | 555 | echo "Querying changelog from Git/SVN\n"; |
556 | 556 | if (!isset($config['modules'])) |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | // query changelog per repo |
561 | 561 | $changelog = ''; |
562 | 562 | $last_tag = null; |
563 | - foreach($config['modules'] as $branch_url => $modules) |
|
563 | + foreach ($config['modules'] as $branch_url => $modules) |
|
564 | 564 | { |
565 | 565 | $revision = null; |
566 | 566 | if (substr($branch_url, -4) == '.git') |
@@ -573,15 +573,15 @@ discard block |
||
573 | 573 | $changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision); |
574 | 574 | } |
575 | 575 | } |
576 | - $logfile = tempnam('/tmp','checkout-build-archives'); |
|
577 | - file_put_contents($logfile,$changelog); |
|
576 | + $logfile = tempnam('/tmp', 'checkout-build-archives'); |
|
577 | + file_put_contents($logfile, $changelog); |
|
578 | 578 | $cmd = $config['editor'].' '.escapeshellarg($logfile); |
579 | 579 | passthru($cmd); |
580 | 580 | $config['changelog'] = file_get_contents($logfile); |
581 | 581 | // remove trailing newlines |
582 | - while (substr($config['changelog'],-1) == "\n") |
|
582 | + while (substr($config['changelog'], -1) == "\n") |
|
583 | 583 | { |
584 | - $config['changelog'] = substr($config['changelog'],0,-1); |
|
584 | + $config['changelog'] = substr($config['changelog'], 0, -1); |
|
585 | 585 | } |
586 | 586 | // allow user to abort, by deleting the changelog |
587 | 587 | if (strlen($config['changelog']) <= 2) |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | run_cmd($cmd); |
607 | 607 | |
608 | 608 | // update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped) |
609 | - do_obs(true); // true: only update debian.changes in obs checkouts |
|
609 | + do_obs(true); // true: only update debian.changes in obs checkouts |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -620,41 +620,41 @@ discard block |
||
620 | 620 | * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages |
621 | 621 | * @return string with changelog |
622 | 622 | */ |
623 | -function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ') |
|
623 | +function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ') |
|
624 | 624 | { |
625 | 625 | //echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n"; |
626 | - global $config,$verbose,$svn; |
|
626 | + global $config, $verbose, $svn; |
|
627 | 627 | |
628 | 628 | if (is_null($revision)) |
629 | 629 | { |
630 | - list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
|
630 | + list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url); |
|
631 | 631 | if (empty($branch)) $branch = $config['version']; |
632 | 632 | $tags_url .= '/tags'; |
633 | - $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
|
633 | + $pattern = '|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
|
634 | 634 | $matches = null; |
635 | - $revision = get_last_svn_tag($tags_url,$pattern,$matches); |
|
635 | + $revision = get_last_svn_tag($tags_url, $pattern, $matches); |
|
636 | 636 | $tag = $matches[1]; |
637 | 637 | } |
638 | - elseif(!is_numeric($revision)) |
|
638 | + elseif (!is_numeric($revision)) |
|
639 | 639 | { |
640 | - $revision = get_last_svn_tag($tags_url,$tag=$revision); |
|
640 | + $revision = get_last_svn_tag($tags_url, $tag = $revision); |
|
641 | 641 | } |
642 | 642 | $cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url); |
643 | 643 | if (($v = $verbose)) |
644 | 644 | { |
645 | 645 | echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n"; |
646 | - $verbose = false; // otherwise no $output! |
|
646 | + $verbose = false; // otherwise no $output! |
|
647 | 647 | } |
648 | 648 | $output = array(); |
649 | - run_cmd($cmd,$output); |
|
649 | + run_cmd($cmd, $output); |
|
650 | 650 | $verbose = $v; |
651 | - array_shift($output); // remove the command |
|
651 | + array_shift($output); // remove the command |
|
652 | 652 | |
653 | - $xml = simplexml_load_string($output=implode("\n",$output)); |
|
653 | + $xml = simplexml_load_string($output = implode("\n", $output)); |
|
654 | 654 | $message = ''; |
655 | - foreach($xml as $log) |
|
655 | + foreach ($xml as $log) |
|
656 | 656 | { |
657 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
657 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
658 | 658 | |
659 | 659 | $message .= $msg."\n"; |
660 | 660 | } |
@@ -671,25 +671,25 @@ discard block |
||
671 | 671 | * @param string $prefix ='* ' |
672 | 672 | * @return string |
673 | 673 | */ |
674 | -function _match_log_pattern($msg, $log_pattern, $prefix='* ') |
|
674 | +function _match_log_pattern($msg, $log_pattern, $prefix = '* ') |
|
675 | 675 | { |
676 | 676 | $pattern_len = strlen($log_pattern); |
677 | 677 | $prefix_len = strlen($prefix); |
678 | 678 | |
679 | 679 | $matches = null; |
680 | - if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches)) |
|
680 | + if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches)) |
|
681 | 681 | { |
682 | 682 | $msg = $matches[1]; |
683 | 683 | } |
684 | - elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern) |
|
684 | + elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern) |
|
685 | 685 | { |
686 | - list($msg) = explode("\n",$msg); |
|
686 | + list($msg) = explode("\n", $msg); |
|
687 | 687 | } |
688 | - elseif($log_pattern) |
|
688 | + elseif ($log_pattern) |
|
689 | 689 | { |
690 | 690 | return null; |
691 | 691 | } |
692 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
692 | + if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg; |
|
693 | 693 | |
694 | 694 | return $msg; |
695 | 695 | } |
@@ -703,30 +703,30 @@ discard block |
||
703 | 703 | * @param array &$matches=null on return matches of preg_match |
704 | 704 | * @return int revision of last svn tag matching pattern |
705 | 705 | */ |
706 | -function get_last_svn_tag($tags_url,$pattern,&$matches=null) |
|
706 | +function get_last_svn_tag($tags_url, $pattern, &$matches = null) |
|
707 | 707 | { |
708 | - global $verbose,$svn; |
|
708 | + global $verbose, $svn; |
|
709 | 709 | |
710 | 710 | $cmd = $svn.' log --xml --limit 40 -v '.escapeshellarg($tags_url); |
711 | 711 | if (($v = $verbose)) |
712 | 712 | { |
713 | 713 | echo "Querying SVN for last tags\n$cmd\n"; |
714 | - $verbose = false; // otherwise no $output! |
|
714 | + $verbose = false; // otherwise no $output! |
|
715 | 715 | } |
716 | 716 | $output = array(); |
717 | - run_cmd($cmd,$output); |
|
717 | + run_cmd($cmd, $output); |
|
718 | 718 | $verbose = $v; |
719 | - array_shift($output); // remove the command |
|
719 | + array_shift($output); // remove the command |
|
720 | 720 | |
721 | - $xml = simplexml_load_string($output=implode("\n",$output)); |
|
721 | + $xml = simplexml_load_string($output = implode("\n", $output)); |
|
722 | 722 | $is_regexp = $pattern[0] == substr($pattern, -1); |
723 | - foreach($xml as $log) |
|
723 | + foreach ($xml as $log) |
|
724 | 724 | { |
725 | 725 | //print_r($log); |
726 | 726 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
727 | 727 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
728 | 728 | { |
729 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
729 | + if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n"; |
|
730 | 730 | return (int)$log['revision']; |
731 | 731 | } |
732 | 732 | } |
@@ -738,9 +738,9 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it |
740 | 740 | */ |
741 | -function do_obs($only_update_changelog=false) |
|
741 | +function do_obs($only_update_changelog = false) |
|
742 | 742 | { |
743 | - global $config,$verbose; |
|
743 | + global $config, $verbose; |
|
744 | 744 | |
745 | 745 | if (!is_dir($config['obs'])) |
746 | 746 | { |
@@ -750,25 +750,25 @@ discard block |
||
750 | 750 | run_cmd('osc up '.$config['obs']); |
751 | 751 | |
752 | 752 | $n = 0; |
753 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) |
|
753 | + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) |
|
754 | 754 | { |
755 | 755 | if (basename(dirname($path)) == '.osc' || |
756 | 756 | !preg_match('/\/('.preg_quote($config['packagename']). |
757 | 757 | ($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : ''). |
758 | - ')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/',$path)) |
|
758 | + ')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/', $path)) |
|
759 | 759 | { |
760 | 760 | continue; |
761 | 761 | } |
762 | 762 | $matches = null; |
763 | - if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) && |
|
764 | - file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) |
|
763 | + if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) && |
|
764 | + file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) |
|
765 | 765 | { |
766 | 766 | if (basename($path) != basename($new_name)) |
767 | 767 | { |
768 | 768 | unlink($path); |
769 | 769 | if ($verbose) echo "rm $path\n"; |
770 | 770 | } |
771 | - copy($new_name,dirname($path).'/'.basename($new_name)); |
|
771 | + copy($new_name, dirname($path).'/'.basename($new_name)); |
|
772 | 772 | if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
773 | 773 | ++$n; |
774 | 774 | } |
@@ -778,35 +778,35 @@ discard block |
||
778 | 778 | $config['changelog'] = parse_current_changelog(); |
779 | 779 | } |
780 | 780 | // updating dsc, spec and changelog files |
781 | - if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') || |
|
781 | + if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') || |
|
782 | 782 | !empty($config['changelog']) && basename($path) == 'debian.changes') |
783 | 783 | { |
784 | 784 | $content = $content_was = file_get_contents($path); |
785 | 785 | |
786 | - if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') |
|
786 | + if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') |
|
787 | 787 | { |
788 | - $content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content); |
|
788 | + $content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content); |
|
789 | 789 | } |
790 | - if (substr($path,-4) == '.dsc') |
|
790 | + if (substr($path, -4) == '.dsc') |
|
791 | 791 | { |
792 | 792 | $content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'. |
793 | 793 | preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m', |
794 | - '\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content); |
|
794 | + '\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content); |
|
795 | 795 | } |
796 | - if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false) |
|
796 | + if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false) |
|
797 | 797 | { |
798 | 798 | $content = update_changelog($content); |
799 | 799 | } |
800 | - if (!empty($config['changelog']) && substr($path,-5) == '.spec' && |
|
801 | - ($pos_changelog = strpos($content,'%changelog')) !== false) |
|
800 | + if (!empty($config['changelog']) && substr($path, -5) == '.spec' && |
|
801 | + ($pos_changelog = strpos($content, '%changelog')) !== false) |
|
802 | 802 | { |
803 | 803 | $pos_changelog += strlen("%changelog\n"); |
804 | - $content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n". |
|
805 | - $config['changelog']."\n".substr($content,$pos_changelog); |
|
804 | + $content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n". |
|
805 | + $config['changelog']."\n".substr($content, $pos_changelog); |
|
806 | 806 | } |
807 | 807 | if ($content != $content_was) |
808 | 808 | { |
809 | - file_put_contents($path,$content); |
|
809 | + file_put_contents($path, $content); |
|
810 | 810 | if ($verbose) echo "Updated $path\n"; |
811 | 811 | ++$n; |
812 | 812 | } |
@@ -827,33 +827,33 @@ discard block |
||
827 | 827 | * @param boolean $set_packaging =false true: set packaging from last changelog entry |
828 | 828 | * @return string changelog entries without header and footer lines |
829 | 829 | */ |
830 | -function parse_current_changelog($set_packaging=false) |
|
830 | +function parse_current_changelog($set_packaging = false) |
|
831 | 831 | { |
832 | 832 | global $config; |
833 | 833 | |
834 | 834 | $changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes'); |
835 | 835 | $lines = explode("\n", $changelog, 100); |
836 | 836 | $matches = null; |
837 | - foreach($lines as $n => $line) |
|
837 | + foreach ($lines as $n => $line) |
|
838 | 838 | { |
839 | - if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'. |
|
839 | + if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'. |
|
840 | 840 | ($set_packaging ? '([0-9]+)' : preg_quote($config['packaging'])).'/', $line, $matches)) |
841 | 841 | { |
842 | 842 | if ($set_packaging) |
843 | 843 | { |
844 | 844 | $config['packaging'] = $matches[1]; |
845 | 845 | } |
846 | - $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
|
846 | + $n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header |
|
847 | 847 | $logentry = ''; |
848 | - while($lines[$n]) // entry is terminated by empty line |
|
848 | + while ($lines[$n]) // entry is terminated by empty line |
|
849 | 849 | { |
850 | 850 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
851 | 851 | ++$n; |
852 | 852 | } |
853 | - return substr($logentry, 0, -1); // remove training "\n" |
|
853 | + return substr($logentry, 0, -1); // remove training "\n" |
|
854 | 854 | } |
855 | 855 | } |
856 | - return null; // paragraph for current version NOT found |
|
856 | + return null; // paragraph for current version NOT found |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -867,8 +867,8 @@ discard block |
||
867 | 867 | global $config; |
868 | 868 | |
869 | 869 | list($header) = explode("\n", $content); |
870 | - $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
|
871 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
870 | + $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/', '('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
|
871 | + if (substr($config['changelog'], 0, 2) != ' ') $config['changelog'] = ' '.implode("\n ", explode("\n", $config['changelog'])); |
|
872 | 872 | $content = $new_header."\n\n".$config['changelog']. |
873 | 873 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
874 | 874 | |
@@ -882,9 +882,9 @@ discard block |
||
882 | 882 | { |
883 | 883 | global $config; |
884 | 884 | |
885 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
885 | + if (substr($config['sourcedir'], 0, 2) == '~/') // sha1_file cant deal with '~/rpm' |
|
886 | 886 | { |
887 | - $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
|
887 | + $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1); |
|
888 | 888 | } |
889 | 889 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
890 | 890 | |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
904 | 904 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
905 | 905 | run_cmd($cmd); |
906 | - unlink($sumsfile); // delete the unsigned file |
|
906 | + unlink($sumsfile); // delete the unsigned file |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | /** |
@@ -913,22 +913,22 @@ discard block |
||
913 | 913 | { |
914 | 914 | global $config; |
915 | 915 | |
916 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
917 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
916 | + if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true); |
|
917 | + if (substr($config['sourcedir'], 0, 2) == '~/') // sha1_file cant deal with '~/rpm' |
|
918 | 918 | { |
919 | - $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
|
919 | + $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1); |
|
920 | 920 | } |
921 | 921 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
922 | 922 | $sums = ''; |
923 | 923 | |
924 | 924 | chdir($config['egw_buildroot']); |
925 | 925 | |
926 | - if($config['extra']) |
|
926 | + if ($config['extra']) |
|
927 | 927 | { |
928 | 928 | $exclude = $exclude_all = array(); |
929 | - foreach($config['extra'] as $name => $modules) |
|
929 | + foreach ($config['extra'] as $name => $modules) |
|
930 | 930 | { |
931 | - foreach((array)$modules as $module) |
|
931 | + foreach ((array)$modules as $module) |
|
932 | 932 | { |
933 | 933 | $exclude[] = basename($module); |
934 | 934 | if (!empty($config['all-add']) && !in_array($module, $config['all-add']) && (is_int($name) || !in_array($name, $config['all-add']))) |
@@ -938,24 +938,24 @@ discard block |
||
938 | 938 | } |
939 | 939 | } |
940 | 940 | $exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude); |
941 | - $exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : ''; |
|
941 | + $exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : ''; |
|
942 | 942 | } |
943 | - foreach($config['types'] as $type) |
|
943 | + foreach ($config['types'] as $type) |
|
944 | 944 | { |
945 | 945 | echo "Creating $type archives\n"; |
946 | 946 | $tar_type = $type == 'tar.bz2' ? 'j' : 'z'; |
947 | 947 | |
948 | 948 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
949 | - switch($type) |
|
949 | + switch ($type) |
|
950 | 950 | { |
951 | 951 | case 'all.tar.bz2': // single tar-ball for debian builds not easily supporting to use multiple |
952 | 952 | $file = $config['sourcedir'].'/'.$config['packagename'].'-all-'.$config['version'].'.'.$config['packaging'].'.tar'; |
953 | 953 | $cmd = $config['tar'].' --owner=root --group=root -cf '.$file.$exclude_all_extra.' egroupware'; |
954 | 954 | if (!empty($config['all-add'])) |
955 | 955 | { |
956 | - foreach((array)$config['all-add'] as $add) |
|
956 | + foreach ((array)$config['all-add'] as $add) |
|
957 | 957 | { |
958 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
958 | + if (substr($add, -4) != '.tar') continue; // probably a module |
|
959 | 959 | if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
960 | 960 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
961 | 961 | } |
@@ -979,15 +979,15 @@ discard block |
||
979 | 979 | run_cmd($cmd); |
980 | 980 | $sums .= sha1_file($file)."\t".basename($file)."\n"; |
981 | 981 | |
982 | - foreach($config['extra'] as $name => $modules) |
|
982 | + foreach ($config['extra'] as $name => $modules) |
|
983 | 983 | { |
984 | 984 | if (is_numeric($name)) $name = $modules; |
985 | 985 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
986 | 986 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
987 | - switch($type) |
|
987 | + switch ($type) |
|
988 | 988 | { |
989 | 989 | case 'all.tar.bz2': |
990 | - break; // nothing to do |
|
990 | + break; // nothing to do |
|
991 | 991 | case 'tar.bz2': |
992 | 992 | case 'tar.gz': |
993 | 993 | $cmd = $config['tar'].' --owner=root --group=root -c'.$tar_type.'f '.$file.$dirs; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | } |
1003 | 1003 | } |
1004 | 1004 | // writing sha1sum file |
1005 | - file_put_contents($sumsfile,$sums); |
|
1005 | + file_put_contents($sumsfile, $sums); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | */ |
1011 | 1011 | function do_virusscan() |
1012 | 1012 | { |
1013 | - global $config,$verbose; |
|
1013 | + global $config, $verbose; |
|
1014 | 1014 | |
1015 | 1015 | if (!file_exists($config['clamscan']) || !is_executable($config['clamscan'])) |
1016 | 1016 | { |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
1025 | 1025 | if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
1026 | 1026 | $output = null; |
1027 | - run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
|
1027 | + run_cmd($cmd, $output, 1); // 1 = ignore already up to date database |
|
1028 | 1028 | } |
1029 | 1029 | echo "Starting virusscan\n"; |
1030 | 1030 | $cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot']; |
@@ -1081,12 +1081,12 @@ discard block |
||
1081 | 1081 | */ |
1082 | 1082 | function do_svncheckout() |
1083 | 1083 | { |
1084 | - global $config,$svn; |
|
1084 | + global $config, $svn; |
|
1085 | 1085 | |
1086 | 1086 | echo "Starting svn checkout/update\n"; |
1087 | 1087 | if (!file_exists($config['checkoutdir'])) |
1088 | 1088 | { |
1089 | - mkdir($config['checkoutdir'],0755,true); |
|
1089 | + mkdir($config['checkoutdir'], 0755, true); |
|
1090 | 1090 | } |
1091 | 1091 | elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir'])) |
1092 | 1092 | { |
@@ -1101,17 +1101,17 @@ discard block |
||
1101 | 1101 | { |
1102 | 1102 | get_modules_per_repo(); |
1103 | 1103 | } |
1104 | - $config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name |
|
1104 | + $config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name |
|
1105 | 1105 | |
1106 | 1106 | if (file_exists($config['aliasdir'])) |
1107 | 1107 | { |
1108 | - system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags |
|
1108 | + system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags |
|
1109 | 1109 | clearstatcache(); |
1110 | 1110 | } |
1111 | - foreach($config['modules'] as $repo => $modules) |
|
1111 | + foreach ($config['modules'] as $repo => $modules) |
|
1112 | 1112 | { |
1113 | 1113 | $cmd = $svn.' co '; |
1114 | - foreach($modules as $path => $url) |
|
1114 | + foreach ($modules as $path => $url) |
|
1115 | 1115 | { |
1116 | 1116 | if ($path == $config['aliasdir']) |
1117 | 1117 | { |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | $cmd = $svn.' co '; |
1122 | 1122 | continue; |
1123 | 1123 | } |
1124 | - if(file_exists($config['aliasdir'])) |
|
1124 | + if (file_exists($config['aliasdir'])) |
|
1125 | 1125 | { |
1126 | 1126 | die("'egroupware' applications must be first one in externals!\n"); |
1127 | 1127 | } |
@@ -1139,16 +1139,16 @@ discard block |
||
1139 | 1139 | // check if correct branch |
1140 | 1140 | $cmd = 'LANG=C '.$svn.' info'; |
1141 | 1141 | $output = $ret = null; |
1142 | - exec($cmd,$output,$ret); |
|
1143 | - foreach($output as $line) |
|
1142 | + exec($cmd, $output, $ret); |
|
1143 | + foreach ($output as $line) |
|
1144 | 1144 | { |
1145 | - if ($ret || substr($line,0,5) == 'URL: ') |
|
1145 | + if ($ret || substr($line, 0, 5) == 'URL: ') |
|
1146 | 1146 | { |
1147 | - $url = substr($line,5); |
|
1148 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
1147 | + $url = substr($line, 5); |
|
1148 | + if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
1149 | 1149 | { |
1150 | 1150 | echo "Checkout is of wrong branch --> deleting it\n"; |
1151 | - system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
|
1151 | + system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
|
1152 | 1152 | clearstatcache(); |
1153 | 1153 | } |
1154 | 1154 | break; |
@@ -1160,10 +1160,10 @@ discard block |
||
1160 | 1160 | run_cmd($cmd); |
1161 | 1161 | |
1162 | 1162 | chdir($config['aliasdir']); |
1163 | - foreach($config['extra'] as $module) |
|
1163 | + foreach ($config['extra'] as $module) |
|
1164 | 1164 | { |
1165 | - $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1166 | - $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
|
1165 | + $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1166 | + $url = strpos($module, '://') === false ? $svnbranch.'/' : ''; |
|
1167 | 1167 | $url .= $module; |
1168 | 1168 | $cmd = $svn.' co '.$url; |
1169 | 1169 | run_cmd($cmd); |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | */ |
1189 | 1189 | function get_modules_per_svn_repo() |
1190 | 1190 | { |
1191 | - global $config,$svn,$verbose; |
|
1191 | + global $config, $svn, $verbose; |
|
1192 | 1192 | |
1193 | 1193 | // process alias/externals |
1194 | 1194 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
@@ -1196,27 +1196,27 @@ discard block |
||
1196 | 1196 | $cmd = $svn.' propget svn:externals --strict '.$url; |
1197 | 1197 | if ($verbose) echo $cmd."\n"; |
1198 | 1198 | $output = $ret = null; |
1199 | - exec($cmd,$output,$ret); |
|
1199 | + exec($cmd, $output, $ret); |
|
1200 | 1200 | $config['modules'] = array(); |
1201 | - foreach($output as $line) |
|
1201 | + foreach ($output as $line) |
|
1202 | 1202 | { |
1203 | 1203 | $line = trim($line); |
1204 | 1204 | if (empty($line) || $line[0] == '#') continue; |
1205 | - list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
|
1205 | + list($path, $url) = preg_split('/[ \t\r\n]+/', $line); |
|
1206 | 1206 | $matches = null; |
1207 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1207 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n"); |
|
1208 | 1208 | $repo = $matches[1]; |
1209 | 1209 | if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
1210 | 1210 | $config['modules'][$repo][$path] = $url; |
1211 | 1211 | } |
1212 | 1212 | // process extra modules |
1213 | - foreach($config['extra'] as $module) |
|
1213 | + foreach ($config['extra'] as $module) |
|
1214 | 1214 | { |
1215 | - $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1216 | - $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
|
1215 | + $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1216 | + $url = strpos($module, '://') === false ? $svnbranch.'/' : ''; |
|
1217 | 1217 | $url .= $module; |
1218 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
1219 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1218 | + if (strpos($module, '://') !== false) $module = basename($module); |
|
1219 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n"); |
|
1220 | 1220 | $repo = $matches[1]; |
1221 | 1221 | if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
1222 | 1222 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
@@ -1230,11 +1230,11 @@ discard block |
||
1230 | 1230 | */ |
1231 | 1231 | function do_svntag() |
1232 | 1232 | { |
1233 | - global $config,$svn; |
|
1233 | + global $config, $svn; |
|
1234 | 1234 | |
1235 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
1235 | + if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
1236 | 1236 | |
1237 | - $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
|
1237 | + $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
|
1238 | 1238 | |
1239 | 1239 | echo "Creating SVN tag $config[svntag]\n"; |
1240 | 1240 | if (!isset($config['modules'])) |
@@ -1242,9 +1242,9 @@ discard block |
||
1242 | 1242 | get_modules_per_repo(); |
1243 | 1243 | } |
1244 | 1244 | // create tags (per repo) |
1245 | - foreach($config['modules'] as $repo => $modules) |
|
1245 | + foreach ($config['modules'] as $repo => $modules) |
|
1246 | 1246 | { |
1247 | - $cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/'; |
|
1247 | + $cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/'; |
|
1248 | 1248 | run_cmd($cmd); |
1249 | 1249 | } |
1250 | 1250 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * @param int|array $no_bailout =null exit code(s) to NOT bail out |
1258 | 1258 | * @return int exit code of $cmd |
1259 | 1259 | */ |
1260 | -function run_cmd($cmd,array &$output=null,$no_bailout=null) |
|
1260 | +function run_cmd($cmd, array &$output = null, $no_bailout = null) |
|
1261 | 1261 | { |
1262 | 1262 | global $verbose; |
1263 | 1263 | |
@@ -1265,18 +1265,18 @@ discard block |
||
1265 | 1265 | { |
1266 | 1266 | echo $cmd."\n"; |
1267 | 1267 | $ret = null; |
1268 | - system($cmd,$ret); |
|
1268 | + system($cmd, $ret); |
|
1269 | 1269 | } |
1270 | 1270 | else |
1271 | 1271 | { |
1272 | 1272 | $output[] = $cmd; |
1273 | - exec($cmd,$output,$ret); |
|
1274 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
1273 | + exec($cmd, $output, $ret); |
|
1274 | + if ($verbose) echo implode("\n", $output)."\n"; |
|
1275 | 1275 | } |
1276 | - if ($ret && !in_array($ret,(array)$no_bailout)) |
|
1276 | + if ($ret && !in_array($ret, (array)$no_bailout)) |
|
1277 | 1277 | { |
1278 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
1279 | - throw new Exception("Error during '$cmd' --> aborting",$ret); |
|
1278 | + if (!$verbose) echo implode("\n", $output)."\n"; |
|
1279 | + throw new Exception("Error during '$cmd' --> aborting", $ret); |
|
1280 | 1280 | } |
1281 | 1281 | return $ret; |
1282 | 1282 | } |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | return 'NULL'; |
1304 | 1304 | case 'object': |
1305 | 1305 | case 'array': |
1306 | - return str_replace(array("\n",' '/*,'Array'*/),'',print_r($var,true)); |
|
1306 | + return str_replace(array("\n", ' '/*,'Array'*/), '', print_r($var, true)); |
|
1307 | 1307 | } |
1308 | 1308 | return 'UNKNOWN TYPE!'; |
1309 | 1309 | } |
@@ -1313,9 +1313,9 @@ discard block |
||
1313 | 1313 | * |
1314 | 1314 | * @param string $error =null optional error-message |
1315 | 1315 | */ |
1316 | -function usage($error=null) |
|
1316 | +function usage($error = null) |
|
1317 | 1317 | { |
1318 | - global $prog,$config,$verbose; |
|
1318 | + global $prog, $config, $verbose; |
|
1319 | 1319 | |
1320 | 1320 | echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n"; |
1321 | 1321 | echo "options and their defaults:\n"; |
@@ -1325,12 +1325,12 @@ discard block |
||
1325 | 1325 | } |
1326 | 1326 | else |
1327 | 1327 | { |
1328 | - unset($config['modules']); // they give an error, because of nested array and are quite lengthy |
|
1328 | + unset($config['modules']); // they give an error, because of nested array and are quite lengthy |
|
1329 | 1329 | } |
1330 | - foreach($config as $name => $default) |
|
1330 | + foreach ($config as $name => $default) |
|
1331 | 1331 | { |
1332 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
1333 | - echo '--'.str_pad($name,20).$default."\n"; |
|
1332 | + if (is_array($default)) $default = json_encode($default, JSON_UNESCAPED_SLASHES); |
|
1333 | + echo '--'.str_pad($name, 20).$default."\n"; |
|
1334 | 1334 | } |
1335 | 1335 | if ($error) |
1336 | 1336 | { |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @param string $cmd |
487 | 487 | * @param array &$output=null $output of command |
488 | - * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
|
488 | + * @param integer $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
|
489 | 489 | * @return int exit code of $cmd |
490 | 490 | */ |
491 | 491 | function run_cmd($cmd,array &$output=null,$no_bailout=null) |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * Read one Univention secret/password eg. _ucr_secret('mysql') |
713 | 713 | * |
714 | 714 | * @param string $name |
715 | - * @return string|boolean |
|
715 | + * @return false|string |
|
716 | 716 | */ |
717 | 717 | function _ucr_secret($name) |
718 | 718 | { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | 'php' => '/usr/bin/php', |
19 | 19 | 'source_dir' => '/usr/share/egroupware', |
20 | 20 | 'data_dir' => '/var/lib/egroupware', |
21 | - 'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm |
|
21 | + 'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm |
|
22 | 22 | 'setup-cli' => '$source_dir/setup/setup-cli.php', |
23 | 23 | 'domain' => 'default', |
24 | 24 | 'config_user' => 'admin', |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | 'db_user' => 'egroupware', |
31 | 31 | 'db_pass' => randomstring(), |
32 | 32 | 'db_grant_host' => 'localhost', |
33 | - 'db_root' => 'root', // mysql root user/pw to create database |
|
33 | + 'db_root' => 'root', // mysql root user/pw to create database |
|
34 | 34 | 'db_root_pw' => '', |
35 | 35 | 'backup' => '', |
36 | 36 | 'admin_user' => 'sysop', |
37 | 37 | 'admin_passwd'=> randomstring(), |
38 | 38 | 'admin_email' => '', |
39 | - 'lang' => 'en', // languages for admin user and extra lang to install |
|
39 | + 'lang' => 'en', // languages for admin user and extra lang to install |
|
40 | 40 | 'charset' => 'utf-8', |
41 | 41 | 'start_db' => '/sbin/service mysqld', |
42 | 42 | 'autostart_db' => '/sbin/chkconfig --level 345 mysqld on', |
@@ -56,23 +56,23 @@ discard block |
||
56 | 56 | 'ldap_search_filter' => '(uid=%user)', |
57 | 57 | 'ldap_group_context' => 'ou=groups,$base', |
58 | 58 | 'ldap_encryption_type' => '', |
59 | - 'sambaadmin/sambasid'=> '', // SID for sambaadmin |
|
59 | + 'sambaadmin/sambasid'=> '', // SID for sambaadmin |
|
60 | 60 | 'mailserver' => '', |
61 | 61 | 'smtpserver' => 'localhost,25', |
62 | - 'smtp' => '', // see setup-cli.php --help config |
|
62 | + 'smtp' => '', // see setup-cli.php --help config |
|
63 | 63 | 'imap' => '', |
64 | 64 | 'sieve' => '', |
65 | 65 | 'folder' => '', |
66 | - 'install-update-app' => '', // install or update a single (non-default) app |
|
67 | - 'webserver_user'=> 'apache', // required to fix permissions |
|
66 | + 'install-update-app' => '', // install or update a single (non-default) app |
|
67 | + 'webserver_user'=> 'apache', // required to fix permissions |
|
68 | 68 | 'php5enmod' => '', |
69 | 69 | ); |
70 | 70 | |
71 | 71 | // read language from LANG enviroment variable |
72 | 72 | if (($lang = isset($_ENV['LANG']) ? $_ENV['LANG'] : (isset($_SERVER['LANG']) ? $_SERVER['LANG'] : null))) |
73 | 73 | { |
74 | - @list($lang,$nat) = preg_split('/[_.]/',$lang); |
|
75 | - if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw'))) |
|
74 | + @list($lang, $nat) = preg_split('/[_.]/', $lang); |
|
75 | + if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw'))) |
|
76 | 76 | { |
77 | 77 | $lang .= '-'.strtolower($nat); |
78 | 78 | } |
@@ -85,16 +85,13 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param string $distro =null default autodetect |
87 | 87 | */ |
88 | -function set_distro_defaults($distro=null) |
|
88 | +function set_distro_defaults($distro = null) |
|
89 | 89 | { |
90 | 90 | global $config; |
91 | 91 | if (is_null($distro)) |
92 | 92 | { |
93 | - $distro = file_exists('/etc/SuSE-release') ? 'suse' : |
|
94 | - (file_exists('/etc/mandriva-release') ? 'mandriva' : |
|
95 | - (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi', |
|
96 | - file_get_contents('/etc/lsb-release')) ? 'univention' : |
|
97 | - (file_exists('/etc/debian_version') ? 'debian' : 'rh'))); |
|
93 | + $distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi', |
|
94 | + file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh'))); |
|
98 | 95 | } |
99 | 96 | switch (($config['distro'] = $distro)) |
100 | 97 | { |
@@ -162,9 +159,9 @@ discard block |
||
162 | 159 | } |
163 | 160 | elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql')) |
164 | 161 | { |
165 | - foreach(array('start_db','autostart_db') as $name) |
|
162 | + foreach (array('start_db', 'autostart_db') as $name) |
|
166 | 163 | { |
167 | - $config[$name] = str_replace('mysqld','mysql',$config[$name]); |
|
164 | + $config[$name] = str_replace('mysqld', 'mysql', $config[$name]); |
|
168 | 165 | } |
169 | 166 | } |
170 | 167 | break; |
@@ -180,48 +177,48 @@ discard block |
||
180 | 177 | if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL'])) |
181 | 178 | { |
182 | 179 | $conf = array(); |
183 | - $config_set = preg_split('/[ \t]+/',trim($config_set)); |
|
184 | - while($config_set) |
|
180 | + $config_set = preg_split('/[ \t]+/', trim($config_set)); |
|
181 | + while ($config_set) |
|
185 | 182 | { |
186 | 183 | $val = array_shift($config_set); |
187 | 184 | if (($quote = $val[0]) == "'" || $quote == '"') // arguments might be quoted with ' or " |
188 | 185 | { |
189 | - while (substr($val,-1) != $quote) |
|
186 | + while (substr($val, -1) != $quote) |
|
190 | 187 | { |
191 | 188 | if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!'); |
192 | 189 | $val .= ' '.array_shift($config_set); |
193 | 190 | } |
194 | - $val = substr($val,1,-1); |
|
191 | + $val = substr($val, 1, -1); |
|
195 | 192 | } |
196 | 193 | $conf[] = $val; |
197 | 194 | } |
198 | - $argv = array_merge($conf,$argv); |
|
195 | + $argv = array_merge($conf, $argv); |
|
199 | 196 | } |
200 | 197 | |
201 | 198 | $auth_type_given = false; |
202 | -while(($arg = array_shift($argv))) |
|
199 | +while (($arg = array_shift($argv))) |
|
203 | 200 | { |
204 | 201 | if ($arg == '-v' || $arg == '--verbose') |
205 | 202 | { |
206 | 203 | $verbose = true; |
207 | 204 | } |
208 | - elseif($arg == '-h' || $arg == '--help') |
|
205 | + elseif ($arg == '-h' || $arg == '--help') |
|
209 | 206 | { |
210 | 207 | usage(); |
211 | 208 | } |
212 | - elseif($arg == '--suse') |
|
209 | + elseif ($arg == '--suse') |
|
213 | 210 | { |
214 | 211 | set_distro_defaults('suse'); |
215 | 212 | } |
216 | - elseif($arg == '--distro') |
|
213 | + elseif ($arg == '--distro') |
|
217 | 214 | { |
218 | 215 | set_distro_defaults(array_shift($argv)); |
219 | 216 | } |
220 | - elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)])) |
|
217 | + elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)])) |
|
221 | 218 | { |
222 | 219 | $config[$name] = array_shift($argv); |
223 | 220 | |
224 | - switch($name) |
|
221 | + switch ($name) |
|
225 | 222 | { |
226 | 223 | case 'auth_type': |
227 | 224 | $auth_type_given = true; |
@@ -242,18 +239,18 @@ discard block |
||
242 | 239 | } |
243 | 240 | |
244 | 241 | $replace = array(); |
245 | -foreach($config as $name => $value) |
|
242 | +foreach ($config as $name => $value) |
|
246 | 243 | { |
247 | 244 | $replace['$'.$name] = $value; |
248 | - if (strpos($value,'$') !== false) |
|
245 | + if (strpos($value, '$') !== false) |
|
249 | 246 | { |
250 | - $config[$name] = strtr($value,$replace); |
|
247 | + $config[$name] = strtr($value, $replace); |
|
251 | 248 | } |
252 | 249 | } |
253 | 250 | // basic config checks |
254 | -foreach(array('php','source_dir','data_dir','setup-cli') as $name) |
|
251 | +foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name) |
|
255 | 252 | { |
256 | - if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!'); |
|
253 | + if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!'); |
|
257 | 254 | } |
258 | 255 | |
259 | 256 | // fix important php.ini and conf.d/*.ini settings |
@@ -278,7 +275,7 @@ discard block |
||
278 | 275 | } |
279 | 276 | // create database |
280 | 277 | $setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db'; |
281 | - foreach(array('domain','db_type','db_host','db_port','db_name','db_user','db_pass','db_root','db_root_pw','db_grant_host') as $name) |
|
278 | + foreach (array('domain', 'db_type', 'db_host', 'db_port', 'db_name', 'db_user', 'db_pass', 'db_root', 'db_root_pw', 'db_grant_host') as $name) |
|
282 | 279 | { |
283 | 280 | $setup_db .= ' '.escapeshellarg($name.'='.$config[$name]); |
284 | 281 | } |
@@ -286,7 +283,7 @@ discard block |
||
286 | 283 | |
287 | 284 | // check if ldap is required and initialise it |
288 | 285 | // we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql! |
289 | - @list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3); |
|
286 | + @list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3); |
|
290 | 287 | $extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']); |
291 | 288 | $extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type'])); |
292 | 289 | if (empty($rest)) unset($config['account-auth']); |
@@ -297,15 +294,15 @@ discard block |
||
297 | 294 | |
298 | 295 | $setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='. |
299 | 296 | ($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap'); |
300 | - foreach(array( |
|
301 | - 'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw', // non-egw params: only used for create |
|
302 | - 'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context', // egw params |
|
297 | + foreach (array( |
|
298 | + 'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create |
|
299 | + 'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params |
|
303 | 300 | 'ldap_encryption_type', 'sambaadmin/sambasid', |
304 | 301 | ) as $name) |
305 | 302 | { |
306 | - if (strpos($value=$config[$name],'$') !== false) |
|
303 | + if (strpos($value = $config[$name], '$') !== false) |
|
307 | 304 | { |
308 | - $config[$name] = $value = strtr($value,array( |
|
305 | + $config[$name] = $value = strtr($value, array( |
|
309 | 306 | '$suffix' => $config['ldap_suffix'], |
310 | 307 | '$base' => $config['ldap_base'], |
311 | 308 | '$admin_pw' => $config['ldap_admin_pw'], |
@@ -313,7 +310,7 @@ discard block |
||
313 | 310 | } |
314 | 311 | $setup_ldap .= ' '.escapeshellarg($name.'='.$value); |
315 | 312 | |
316 | - if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw'))) |
|
313 | + if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw'))) |
|
317 | 314 | { |
318 | 315 | $extra_config .= ' '.escapeshellarg($name.'='.$value); |
319 | 316 | } |
@@ -346,7 +343,7 @@ discard block |
||
346 | 343 | } |
347 | 344 | // create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error) |
348 | 345 | $setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']); |
349 | - foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name) |
|
346 | + foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name) |
|
350 | 347 | { |
351 | 348 | if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
352 | 349 | } |
@@ -360,7 +357,7 @@ discard block |
||
360 | 357 | // check if webserver is started and start it (permanent) if not |
361 | 358 | if ($config['start_webserver']) |
362 | 359 | { |
363 | - exec(build_cmd('start_webserver', 'status'),$dummy,$ret); |
|
360 | + exec(build_cmd('start_webserver', 'status'), $dummy, $ret); |
|
364 | 361 | if ($ret) |
365 | 362 | { |
366 | 363 | system(build_cmd('start_webserver', 'start')); |
@@ -399,7 +396,7 @@ discard block |
||
399 | 396 | // --> existing install --> update |
400 | 397 | |
401 | 398 | // get user from header and replace password, as we dont know it |
402 | - $old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']); |
|
399 | + $old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']); |
|
403 | 400 | // register a shutdown function to put old password back in any case |
404 | 401 | register_shutdown_function(function() use (&$config, $old_password) |
405 | 402 | { |
@@ -408,18 +405,18 @@ discard block |
||
408 | 405 | |
409 | 406 | // update egroupware |
410 | 407 | $setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd'].',,'.$config['install-update-app']); |
411 | - $ret = run_cmd($setup_update,$output,array(4,15)); |
|
408 | + $ret = run_cmd($setup_update, $output, array(4, 15)); |
|
412 | 409 | |
413 | - switch($ret) |
|
410 | + switch ($ret) |
|
414 | 411 | { |
415 | 412 | case 4: // header needs an update |
416 | 413 | $header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']); |
417 | 414 | run_cmd($header_update); |
418 | - $ret = run_cmd($setup_update,$output,15); |
|
415 | + $ret = run_cmd($setup_update, $output, 15); |
|
419 | 416 | if ($ret != 15) break; |
420 | 417 | // fall through |
421 | 418 | case 15: // missing configuration (eg. mailserver) |
422 | - if (!$verbose) echo implode("\n",(array)$output)."\n"; |
|
419 | + if (!$verbose) echo implode("\n", (array)$output)."\n"; |
|
423 | 420 | break; |
424 | 421 | |
425 | 422 | case 0: |
@@ -462,18 +459,18 @@ discard block |
||
462 | 459 | * @param string $password new password |
463 | 460 | * @return string old password |
464 | 461 | */ |
465 | -function patch_header($filename,&$user,$password) |
|
462 | +function patch_header($filename, &$user, $password) |
|
466 | 463 | { |
467 | 464 | $header = file_get_contents($filename); |
468 | 465 | |
469 | 466 | $umatches = $pmatches = null; |
470 | - if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) || |
|
471 | - !preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches)) |
|
467 | + if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) || |
|
468 | + !preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches)) |
|
472 | 469 | { |
473 | - bail_out(99,"$filename is no regular EGroupware header.inc.php!"); |
|
470 | + bail_out(99, "$filename is no regular EGroupware header.inc.php!"); |
|
474 | 471 | } |
475 | - file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", |
|
476 | - "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header)); |
|
472 | + file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", |
|
473 | + "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header)); |
|
477 | 474 | |
478 | 475 | $user = $umatches[1]; |
479 | 476 | |
@@ -488,7 +485,7 @@ discard block |
||
488 | 485 | * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
489 | 486 | * @return int exit code of $cmd |
490 | 487 | */ |
491 | -function run_cmd($cmd,array &$output=null,$no_bailout=null) |
|
488 | +function run_cmd($cmd, array &$output = null, $no_bailout = null) |
|
492 | 489 | { |
493 | 490 | global $verbose; |
494 | 491 | |
@@ -496,16 +493,16 @@ discard block |
||
496 | 493 | { |
497 | 494 | echo $cmd."\n"; |
498 | 495 | $ret = null; |
499 | - system($cmd,$ret); |
|
496 | + system($cmd, $ret); |
|
500 | 497 | } |
501 | 498 | else |
502 | 499 | { |
503 | 500 | $output[] = $cmd; |
504 | - exec($cmd,$output,$ret); |
|
501 | + exec($cmd, $output, $ret); |
|
505 | 502 | } |
506 | - if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout)) |
|
503 | + if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout)) |
|
507 | 504 | { |
508 | - bail_out($ret,$verbose?null:$output); |
|
505 | + bail_out($ret, $verbose ? null : $output); |
|
509 | 506 | } |
510 | 507 | return $ret; |
511 | 508 | } |
@@ -516,9 +513,9 @@ discard block |
||
516 | 513 | * @param int $ret =1 |
517 | 514 | * @param array|string $output line(s) to output before temination notice |
518 | 515 | */ |
519 | -function bail_out($ret=1,$output=null) |
|
516 | +function bail_out($ret = 1, $output = null) |
|
520 | 517 | { |
521 | - if ($output) echo implode("\n",(array)$output); |
|
518 | + if ($output) echo implode("\n", (array)$output); |
|
522 | 519 | echo "\n\nInstallation failed --> exiting!\n\n"; |
523 | 520 | exit($ret); |
524 | 521 | } |
@@ -529,21 +526,21 @@ discard block |
||
529 | 526 | * @param int $len =16 |
530 | 527 | * @return string |
531 | 528 | */ |
532 | -function randomstring($len=16) |
|
529 | +function randomstring($len = 16) |
|
533 | 530 | { |
534 | 531 | static $usedchars = array( |
535 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
536 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
537 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
538 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', |
|
539 | - '@','!','%','&','(',')','=','?',';',':','#','_','-','<', |
|
540 | - '>','|','[',']','}', // dont add /\,'"{ as we have problems dealing with them |
|
532 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
533 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
534 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
535 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
536 | + '@', '!', '%', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<', |
|
537 | + '>', '|', '[', ']', '}', // dont add /\,'"{ as we have problems dealing with them |
|
541 | 538 | ); |
542 | 539 | |
543 | 540 | $str = ''; |
544 | - for($i=0; $i < $len; $i++) |
|
541 | + for ($i = 0; $i < $len; $i++) |
|
545 | 542 | { |
546 | - $str .= $usedchars[mt_rand(0,count($usedchars)-1)]; |
|
543 | + $str .= $usedchars[mt_rand(0, count($usedchars) - 1)]; |
|
547 | 544 | } |
548 | 545 | return $str; |
549 | 546 | } |
@@ -553,20 +550,20 @@ discard block |
||
553 | 550 | * |
554 | 551 | * @param string $error =null optional error-message |
555 | 552 | */ |
556 | -function usage($error=null) |
|
553 | +function usage($error = null) |
|
557 | 554 | { |
558 | - global $prog,$config; |
|
555 | + global $prog, $config; |
|
559 | 556 | |
560 | 557 | echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n"; |
561 | 558 | echo "options and their defaults:\n"; |
562 | - foreach($config as $name => $default) |
|
559 | + foreach ($config as $name => $default) |
|
563 | 560 | { |
564 | - if (in_array($name, array('postfix','cyrus'))) continue; // do NOT report deprecated options |
|
565 | - if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16) |
|
561 | + if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options |
|
562 | + if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16) |
|
566 | 563 | { |
567 | 564 | $default = '<16 char random string>'; |
568 | 565 | } |
569 | - echo '--'.str_pad($name,20).$default."\n"; |
|
566 | + echo '--'.str_pad($name, 20).$default."\n"; |
|
570 | 567 | } |
571 | 568 | if ($error) |
572 | 569 | { |
@@ -616,8 +613,8 @@ discard block |
||
616 | 613 | $config['distro'] = 'univention'; |
617 | 614 | |
618 | 615 | // set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment |
619 | - @list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default')); |
|
620 | - if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw'))) |
|
616 | + @list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default')); |
|
617 | + if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw'))) |
|
621 | 618 | { |
622 | 619 | $lang .= '-'.strtolower($nat); |
623 | 620 | } |
@@ -642,7 +639,7 @@ discard block |
||
642 | 639 | // ldap password hash (our default blowfish_crypt seems not to work) |
643 | 640 | $config['ldap_encryption_type'] = 'sha512_crypt'; |
644 | 641 | |
645 | - $config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups |
|
642 | + $config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups |
|
646 | 643 | |
647 | 644 | $config['account-auth'] = 'univention,ldap'; |
648 | 645 | |
@@ -652,7 +649,7 @@ discard block |
||
652 | 649 | // mailserver, see setup-cli.php --help config |
653 | 650 | if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) && |
654 | 651 | // only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' && |
655 | - ($domains=_ucr_get('mail/hosteddomains'))) |
|
652 | + ($domains = _ucr_get('mail/hosteddomains'))) |
|
656 | 653 | { |
657 | 654 | if (!is_array($domains)) $domains = explode("\n", $domains); |
658 | 655 | $domain = array_shift($domains); |
@@ -692,12 +689,12 @@ discard block |
||
692 | 689 | */ |
693 | 690 | function _ucr_get($name) |
694 | 691 | { |
695 | - static $values=null; |
|
692 | + static $values = null; |
|
696 | 693 | if (!isset($values)) |
697 | 694 | { |
698 | 695 | $output = $matches = null; |
699 | 696 | exec('/usr/sbin/ucr dump', $output); |
700 | - foreach($output as $line) |
|
697 | + foreach ($output as $line) |
|
701 | 698 | { |
702 | 699 | if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches)) |
703 | 700 | { |
@@ -773,7 +770,7 @@ discard block |
||
773 | 770 | */ |
774 | 771 | function _size_with_unit($size) |
775 | 772 | { |
776 | - switch(strtoupper(substr($size, -1))) |
|
773 | + switch (strtoupper(substr($size, -1))) |
|
777 | 774 | { |
778 | 775 | case 'G': |
779 | 776 | $size *= 1024; |
@@ -9,10 +9,13 @@ discard block |
||
9 | 9 | * @version $Id$ |
10 | 10 | */ |
11 | 11 | |
12 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling post_install as web-page |
|
12 | +if (php_sapi_name() !== 'cli') |
|
13 | +{ |
|
14 | + // security precaution: forbit calling post_install as web-page |
|
13 | 15 | { |
14 | 16 | die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>'); |
15 | 17 | } |
18 | +} |
|
16 | 19 | $verbose = false; |
17 | 20 | $config = array( |
18 | 21 | 'php' => '/usr/bin/php', |
@@ -100,7 +103,10 @@ discard block |
||
100 | 103 | { |
101 | 104 | case 'suse': |
102 | 105 | // openSUSE 12.1+ no longer uses php5 |
103 | - if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5'; |
|
106 | + if (file_exists('/usr/bin/php5')) |
|
107 | + { |
|
108 | + $config['php'] = '/usr/bin/php5'; |
|
109 | + } |
|
104 | 110 | $config['start_db'] = '/sbin/service mysql'; |
105 | 111 | $config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on'; |
106 | 112 | $config['start_webserver'] = '/sbin/service apache2'; |
@@ -145,9 +151,12 @@ discard block |
||
145 | 151 | // fall through |
146 | 152 | case 'rh': |
147 | 153 | // some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld" |
148 | - if (file_exists('/usr/bin/systemctl')) // RHEL 7 |
|
154 | + if (file_exists('/usr/bin/systemctl')) |
|
155 | + { |
|
156 | + // RHEL 7 |
|
149 | 157 | { |
150 | 158 | $config['start_db'] = '/usr/bin/systemctl %s mariadb'; |
159 | + } |
|
151 | 160 | $config['autostart_db'] = build_cmd('start_db', 'enable'); |
152 | 161 | $config['start_webserver'] = '/usr/bin/systemctl %s httpd'; |
153 | 162 | $config['autostart_webserver'] = build_cmd('start_webserver', 'enable'); |
@@ -176,11 +185,14 @@ discard block |
||
176 | 185 | while($config_set) |
177 | 186 | { |
178 | 187 | $val = array_shift($config_set); |
179 | - if (($quote = $val[0]) == "'" || $quote == '"') // arguments might be quoted with ' or " |
|
188 | + if (($quote = $val[0]) == "'" || $quote == '"') |
|
189 | + { |
|
190 | + // arguments might be quoted with ' or " |
|
180 | 191 | { |
181 | 192 | while (substr($val,-1) != $quote) |
182 | 193 | { |
183 | 194 | if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!'); |
195 | + } |
|
184 | 196 | $val .= ' '.array_shift($config_set); |
185 | 197 | } |
186 | 198 | $val = substr($val,1,-1); |
@@ -245,18 +257,24 @@ discard block |
||
245 | 257 | // basic config checks |
246 | 258 | foreach(array('php','source_dir','data_dir','setup-cli') as $name) |
247 | 259 | { |
248 | - if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!'); |
|
249 | -} |
|
260 | + if (!file_exists($config[$name])) |
|
261 | + { |
|
262 | + bail_out(1,$config[$name].' not found!'); |
|
263 | + } |
|
264 | + } |
|
250 | 265 | |
251 | 266 | // fix important php.ini and conf.d/*.ini settings |
252 | 267 | check_fix_php_apc_ini(); |
253 | 268 | |
254 | 269 | $setup_cli = $config['php'].' -d memory_limit=256M '.$config['setup-cli']; |
255 | 270 | |
256 | -if (!file_exists($config['header']) || filesize($config['header']) < 200) // default header redirecting to setup is 147 bytes |
|
271 | +if (!file_exists($config['header']) || filesize($config['header']) < 200) |
|
272 | +{ |
|
273 | + // default header redirecting to setup is 147 bytes |
|
257 | 274 | { |
258 | 275 | // --> new install |
259 | 276 | $extra_config = ''; |
277 | +} |
|
260 | 278 | |
261 | 279 | // check for localhost if database server is started and start it (permanent) if not |
262 | 280 | if ($config['db_host'] == 'localhost' && $config['start_db']) |
@@ -265,7 +283,10 @@ discard block |
||
265 | 283 | if ($ret) |
266 | 284 | { |
267 | 285 | system(build_cmd('start_db', 'start')); |
268 | - if (!empty($config['autostart_db'])) system($config['autostart_db']); |
|
286 | + if (!empty($config['autostart_db'])) |
|
287 | + { |
|
288 | + system($config['autostart_db']); |
|
289 | + } |
|
269 | 290 | } |
270 | 291 | } |
271 | 292 | // create database |
@@ -281,7 +302,10 @@ discard block |
||
281 | 302 | @list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3); |
282 | 303 | $extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']); |
283 | 304 | $extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type'])); |
284 | - if (empty($rest)) unset($config['account-auth']); |
|
305 | + if (empty($rest)) |
|
306 | + { |
|
307 | + unset($config['account-auth']); |
|
308 | + } |
|
285 | 309 | if ($config['account_repository'] == 'ldap' || $config['auth_type'] == 'ldap') |
286 | 310 | { |
287 | 311 | // set account_min_id to 1100 if not specified to NOT clash with system accounts |
@@ -340,7 +364,10 @@ discard block |
||
340 | 364 | $setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']); |
341 | 365 | foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name) |
342 | 366 | { |
343 | - if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
|
367 | + if (!empty($config[$name])) |
|
368 | + { |
|
369 | + $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
|
370 | + } |
|
344 | 371 | } |
345 | 372 | run_cmd($setup_mailserver); |
346 | 373 | |
@@ -356,7 +383,10 @@ discard block |
||
356 | 383 | if ($ret) |
357 | 384 | { |
358 | 385 | system(build_cmd('start_webserver', 'start')); |
359 | - if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']); |
|
386 | + if (!empty($config['autostart_webserver'])) |
|
387 | + { |
|
388 | + system($config['autostart_webserver']); |
|
389 | + } |
|
360 | 390 | } |
361 | 391 | else |
362 | 392 | { |
@@ -408,10 +438,16 @@ discard block |
||
408 | 438 | $header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']); |
409 | 439 | run_cmd($header_update); |
410 | 440 | $ret = run_cmd($setup_update,$output,15); |
411 | - if ($ret != 15) break; |
|
441 | + if ($ret != 15) |
|
442 | + { |
|
443 | + break; |
|
444 | + } |
|
412 | 445 | // fall through |
413 | 446 | case 15: // missing configuration (eg. mailserver) |
414 | - if (!$verbose) echo implode("\n",(array)$output)."\n"; |
|
447 | + if (!$verbose) |
|
448 | + { |
|
449 | + echo implode("\n",(array)$output)."\n"; |
|
450 | + } |
|
415 | 451 | break; |
416 | 452 | |
417 | 453 | case 0: |
@@ -439,9 +475,15 @@ discard block |
||
439 | 475 | { |
440 | 476 | global $config; |
441 | 477 | |
442 | - if (isset($config[$cmd])) $cmd = $config[$cmd]; |
|
478 | + if (isset($config[$cmd])) |
|
479 | + { |
|
480 | + $cmd = $config[$cmd]; |
|
481 | + } |
|
443 | 482 | |
444 | - if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd); |
|
483 | + if (strpos($cmd, '%s')) |
|
484 | + { |
|
485 | + return str_replace('%s', $arg, $cmd); |
|
486 | + } |
|
445 | 487 | |
446 | 488 | return $cmd.' '.$arg; |
447 | 489 | } |
@@ -510,7 +552,10 @@ discard block |
||
510 | 552 | */ |
511 | 553 | function bail_out($ret=1,$output=null) |
512 | 554 | { |
513 | - if ($output) echo implode("\n",(array)$output); |
|
555 | + if ($output) |
|
556 | + { |
|
557 | + echo implode("\n",(array)$output); |
|
558 | + } |
|
514 | 559 | echo "\n\nInstallation failed --> exiting!\n\n"; |
515 | 560 | exit($ret); |
516 | 561 | } |
@@ -553,7 +598,11 @@ discard block |
||
553 | 598 | echo "options and their defaults:\n"; |
554 | 599 | foreach($config as $name => $default) |
555 | 600 | { |
556 | - if (in_array($name, array('postfix','cyrus'))) continue; // do NOT report deprecated options |
|
601 | + if (in_array($name, array('postfix','cyrus'))) |
|
602 | + { |
|
603 | + continue; |
|
604 | + } |
|
605 | + // do NOT report deprecated options |
|
557 | 606 | if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16) |
558 | 607 | { |
559 | 608 | $default = '<16 char random string>'; |
@@ -646,7 +695,10 @@ discard block |
||
646 | 695 | // only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' && |
647 | 696 | ($domains=_ucr_get('mail/hosteddomains'))) |
648 | 697 | { |
649 | - if (!is_array($domains)) $domains = explode("\n", $domains); |
|
698 | + if (!is_array($domains)) |
|
699 | + { |
|
700 | + $domains = explode("\n", $domains); |
|
701 | + } |
|
650 | 702 | $domain = array_shift($domains); |
651 | 703 | // set "use auth with session credentials",tls,"not user editable","further identities" |
652 | 704 | $config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes"; |
@@ -656,13 +708,19 @@ discard block |
||
656 | 708 | { |
657 | 709 | $config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Dovecot'; |
658 | 710 | // default with sieve port to 4190, as config is only available on host mailserver app is installed |
659 | - if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190; |
|
711 | + if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) |
|
712 | + { |
|
713 | + $sieve_port = 4190; |
|
714 | + } |
|
660 | 715 | } |
661 | 716 | else |
662 | 717 | { |
663 | 718 | $config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus'; |
664 | 719 | // default with sieve port to 4190, as config is only available on host mailserver app is installed |
665 | - if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190; |
|
720 | + if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) |
|
721 | + { |
|
722 | + $sieve_port = 4190; |
|
723 | + } |
|
666 | 724 | } |
667 | 725 | // set folders so mail creates them on first login, UCS does not automatic |
668 | 726 | $config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,INBOX/Spam'; |
@@ -727,7 +785,10 @@ discard block |
||
727 | 785 | $shm_size = ini_get('apc.shm_size'); |
728 | 786 | $shm_segments = ini_get('apc.shm_segments'); |
729 | 787 | // ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit |
730 | - if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M'; |
|
788 | + if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) |
|
789 | + { |
|
790 | + $shm_size .= 'M'; |
|
791 | + } |
|
731 | 792 | |
732 | 793 | $size = _size_with_unit($shm_size) * $shm_segments; |
733 | 794 | //echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n"; |
@@ -743,7 +804,10 @@ discard block |
||
743 | 804 | file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path))) |
744 | 805 | { |
745 | 806 | $new_shm_size = 128 / $shm_segments; |
746 | - if (!$numeric_size) $new_shm_size .= 'M'; |
|
807 | + if (!$numeric_size) |
|
808 | + { |
|
809 | + $new_shm_size .= 'M'; |
|
810 | + } |
|
747 | 811 | if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini)) |
748 | 812 | { |
749 | 813 | file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini)); |
@@ -91,7 +91,7 @@ |
||
91 | 91 | /** |
92 | 92 | * Entries for filemanagers's admin menu |
93 | 93 | * |
94 | - * @param string|array $location ='admin' hook name or params |
|
94 | + * @param string $location ='admin' hook name or params |
|
95 | 95 | */ |
96 | 96 | static function admin($location = 'admin') |
97 | 97 | { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ); |
106 | 106 | if ($location == 'admin') |
107 | 107 | { |
108 | - display_section(self::$appname,$file); |
|
108 | + display_section(self::$appname,$file); |
|
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'yes' => lang('Yes') |
129 | 129 | ); |
130 | 130 | |
131 | - $settings = array( |
|
131 | + $settings = array( |
|
132 | 132 | 'startfolder' => array( |
133 | 133 | 'type' => 'input', |
134 | 134 | 'name' => 'startfolder', |
@@ -464,7 +464,7 @@ |
||
464 | 464 | { |
465 | 465 | unset($args); // unused, but required by function signature |
466 | 466 | $appname = 'preferences'; |
467 | - $file = Array( |
|
467 | + $file = array( |
|
468 | 468 | 'Site configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'), |
469 | 469 | ); |
470 | 470 | display_section($appname, $file); |
@@ -85,7 +85,10 @@ discard block |
||
85 | 85 | $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
86 | 86 | display_sidebox(self::$appname,$title,$file); |
87 | 87 | } |
88 | - if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
|
88 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
89 | + { |
|
90 | + self::admin(self::$appname); |
|
91 | + } |
|
89 | 92 | } |
90 | 93 | |
91 | 94 | /** |
@@ -95,7 +98,10 @@ discard block |
||
95 | 98 | */ |
96 | 99 | static function admin($location = 'admin') |
97 | 100 | { |
98 | - if (is_array($location)) $location = $location['location']; |
|
101 | + if (is_array($location)) |
|
102 | + { |
|
103 | + $location = $location['location']; |
|
104 | + } |
|
99 | 105 | |
100 | 106 | $file = Array( |
101 | 107 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | $basepath = '/home'; |
37 | 37 | $homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
38 | 38 | //echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n"; |
39 | - $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
39 | + $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
40 | 40 | if ($location == 'sidebox_menu') |
41 | 41 | { |
42 | - $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu'); |
|
42 | + $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu'); |
|
43 | 43 | $file = array(); |
44 | - if($GLOBALS['egw_info']['apps']['stylite']) |
|
44 | + if ($GLOBALS['egw_info']['apps']['stylite']) |
|
45 | 45 | { |
46 | 46 | // add "file a file" (upload) dialog |
47 | 47 | $file[] = array( |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | // add selection for available views, if we have more then one |
55 | 55 | if (count(filemanager_ui::init_views()) > 1) |
56 | 56 | { |
57 | - $index_url = Egw::link('/index.php',array('menuaction' => 'filemanager.filemanager_ui.index'),false); |
|
57 | + $index_url = Egw::link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index'), false); |
|
58 | 58 | $file[] = array( |
59 | - 'text' => Api\Html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false, |
|
59 | + 'text' => Api\Html::select('filemanager_view', filemanager_ui::get_view(), filemanager_ui::$views, false, |
|
60 | 60 | ' onchange="'."egw_appWindow('filemanager').location='$index_url&view='+this.value;". |
61 | 61 | '" style="width: 100%;"'), |
62 | 62 | 'no_lang' => True, |
@@ -65,23 +65,23 @@ discard block |
||
65 | 65 | } |
66 | 66 | if ($file_prefs['showhome'] != 'no') |
67 | 67 | { |
68 | - $file['Your home directory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$homepath,'ajax'=>'true')); |
|
68 | + $file['Your home directory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$homepath, 'ajax'=>'true')); |
|
69 | 69 | } |
70 | 70 | if ($file_prefs['showusers'] != 'no') |
71 | 71 | { |
72 | - $file['Users and groups'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$basepath,'ajax'=>'true')); |
|
72 | + $file['Users and groups'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$basepath, 'ajax'=>'true')); |
|
73 | 73 | } |
74 | - if (!empty($file_prefs['showbase']) && $file_prefs['showbase']=='yes') |
|
74 | + if (!empty($file_prefs['showbase']) && $file_prefs['showbase'] == 'yes') |
|
75 | 75 | { |
76 | - $file['Basedirectory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true')); |
|
76 | + $file['Basedirectory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$rootpath, 'ajax'=>'true')); |
|
77 | 77 | } |
78 | 78 | if (!empty($file_prefs['startfolder'])) |
79 | 79 | { |
80 | - $file['Startfolder']= Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true')); |
|
80 | + $file['Startfolder'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true')); |
|
81 | 81 | } |
82 | - $file['Placeholders'] = Egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements'); |
|
83 | - $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
84 | - display_sidebox(self::$appname,$title,$file); |
|
82 | + $file['Placeholders'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements'); |
|
83 | + $file['Shared files'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
84 | + display_sidebox(self::$appname, $title, $file); |
|
85 | 85 | } |
86 | 86 | if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
87 | 87 | } |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | |
98 | 98 | $file = Array( |
99 | 99 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
100 | - 'Custom fields' => Egw::link('/index.php','menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'), |
|
101 | - 'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'), |
|
100 | + 'Custom fields' => Egw::link('/index.php', 'menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'), |
|
101 | + 'Check virtual filesystem' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'), |
|
102 | 102 | 'VFS mounts and versioning' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'), |
103 | 103 | ); |
104 | 104 | if ($location == 'admin') |
105 | 105 | { |
106 | - display_section(self::$appname,$file); |
|
106 | + display_section(self::$appname, $file); |
|
107 | 107 | } |
108 | 108 | else |
109 | 109 | { |
110 | - display_sidebox(self::$appname,lang('Admin'),$file); |
|
110 | + display_sidebox(self::$appname, lang('Admin'), $file); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'type' => 'select', |
151 | 151 | 'name' => 'showhome', |
152 | 152 | 'values' => $yes_no, |
153 | - 'label' => lang('Show link "%1" in side box menu?',lang('Your home directory')), |
|
153 | + 'label' => lang('Show link "%1" in side box menu?', lang('Your home directory')), |
|
154 | 154 | 'xmlrpc' => True, |
155 | 155 | 'admin' => False, |
156 | 156 | 'forced' => 'yes', |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'type' => 'select', |
160 | 160 | 'name' => 'showusers', |
161 | 161 | 'values' => $yes_no, |
162 | - 'label' => lang('Show link "%1" in side box menu?',lang('Users and groups')), |
|
162 | + 'label' => lang('Show link "%1" in side box menu?', lang('Users and groups')), |
|
163 | 163 | 'xmlrpc' => True, |
164 | 164 | 'admin' => False, |
165 | 165 | 'forced' => 'yes', |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | 'size' => 60, |
172 | 172 | 'label' => 'Default document to insert entries', |
173 | 173 | 'name' => 'default_document', |
174 | - 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('filemanager')).' '. |
|
174 | + 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('filemanager')).' '. |
|
175 | 175 | lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
176 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
176 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
177 | 177 | 'run_lang' => false, |
178 | 178 | 'xmlrpc' => True, |
179 | 179 | 'admin' => False, |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | 'label' => 'Directory with documents to insert entries', |
185 | 185 | 'name' => 'document_dir', |
186 | 186 | 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('filemanager')).' '. |
187 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '. |
|
188 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
187 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
|
188 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
189 | 189 | 'run_lang' => false, |
190 | 190 | 'xmlrpc' => True, |
191 | 191 | 'admin' => False, |
@@ -127,8 +127,7 @@ |
||
127 | 127 | /** |
128 | 128 | * Show files shared |
129 | 129 | * |
130 | - * @param array $content=null |
|
131 | - * @param string $msg='' |
|
130 | + * @param array $content |
|
132 | 131 | */ |
133 | 132 | public function index(array $content=null) |
134 | 133 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $readonlys = null; |
90 | 90 | $total = Sharing::so()->get_rows($query, $rows, $readonlys); |
91 | 91 | |
92 | - foreach($rows as &$row) |
|
92 | + foreach ($rows as &$row) |
|
93 | 93 | { |
94 | 94 | if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir) |
95 | 95 | { |
@@ -130,21 +130,21 @@ discard block |
||
130 | 130 | * @param array $content=null |
131 | 131 | * @param string $msg='' |
132 | 132 | */ |
133 | - public function index(array $content=null) |
|
133 | + public function index(array $content = null) |
|
134 | 134 | { |
135 | 135 | if (!is_array($content)) |
136 | 136 | { |
137 | 137 | $content = array( |
138 | 138 | 'nm' => array( |
139 | - 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
140 | - 'no_filter' => True, // current dir only |
|
141 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
142 | - 'no_cat' => True, // I disable the cat-selectbox |
|
143 | - 'lettersearch' => false, // I show a lettersearch |
|
144 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
145 | - 'start' => 0, // IO position in list |
|
146 | - 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
147 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
139 | + 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
140 | + 'no_filter' => True, // current dir only |
|
141 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
142 | + 'no_cat' => True, // I disable the cat-selectbox |
|
143 | + 'lettersearch' => false, // I show a lettersearch |
|
144 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
145 | + 'start' => 0, // IO position in list |
|
146 | + 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
147 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
148 | 148 | //'default_cols' => '!', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
149 | 149 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
150 | 150 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | elseif ($content['nm']['action']) |
158 | 158 | { |
159 | - switch($content['nm']['action']) |
|
159 | + switch ($content['nm']['action']) |
|
160 | 160 | { |
161 | 161 | case 'delete': |
162 | 162 | $where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']); |
@@ -101,7 +101,10 @@ |
||
101 | 101 | $row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY; |
102 | 102 | } |
103 | 103 | $row['share_passwd'] = (boolean)$row['share_passwd']; |
104 | - if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
|
104 | + if ($row['share_with']) |
|
105 | + { |
|
106 | + $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
|
107 | + } |
|
105 | 108 | } |
106 | 109 | return $total; |
107 | 110 | } |
@@ -536,6 +536,9 @@ discard block |
||
536 | 536 | * @param int &$errs=null on return number of errors |
537 | 537 | * @param int &$dirs=null on return number of dirs deleted |
538 | 538 | * @param int &$files=null on return number of files deleted |
539 | + * @param integer $errs |
|
540 | + * @param integer $files |
|
541 | + * @param integer $dirs |
|
539 | 542 | * @return string success or failure message displayed to the user |
540 | 543 | */ |
541 | 544 | static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
@@ -704,6 +707,9 @@ discard block |
||
704 | 707 | * @param int &$errs=null on return number of errors |
705 | 708 | * @param int &$dirs=null on return number of dirs deleted |
706 | 709 | * @param int &$files=null on return number of files deleted |
710 | + * @param integer $errs |
|
711 | + * @param integer $dirs |
|
712 | + * @param integer $files |
|
707 | 713 | * @return string |
708 | 714 | */ |
709 | 715 | public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
@@ -1325,7 +1331,6 @@ discard block |
||
1325 | 1331 | * |
1326 | 1332 | * @param string $action eg. 'delete', ... |
1327 | 1333 | * @param array $selected selected path(s) |
1328 | - * @param string $dir=null current directory |
|
1329 | 1334 | * @see static::action() |
1330 | 1335 | */ |
1331 | 1336 | public static function ajax_action($action, $selected, $dir=null, $props=null) |
@@ -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 | } |
@@ -87,7 +87,10 @@ discard block |
||
87 | 87 | // search for plugins with additional filemanager views |
88 | 88 | foreach(Api\Hooks::process('filemanager_views') as $views) |
89 | 89 | { |
90 | - if (is_array($views)) static::$views += $views; |
|
90 | + if (is_array($views)) |
|
91 | + { |
|
92 | + static::$views += $views; |
|
93 | + } |
|
91 | 94 | } |
92 | 95 | static::$views_init = true; |
93 | 96 | } |
@@ -310,7 +313,10 @@ discard block |
||
310 | 313 | $content['nm']['home_dir'] = static::get_home_dir(); |
311 | 314 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
312 | 315 | |
313 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
316 | + if (isset($_GET['msg'])) |
|
317 | + { |
|
318 | + $msg = $_GET['msg']; |
|
319 | + } |
|
314 | 320 | |
315 | 321 | // Blank favorite set via GET needs special handling for path |
316 | 322 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -344,7 +350,10 @@ discard block |
||
344 | 350 | // reset lettersearch as it confuses users (they think the dir is empty) |
345 | 351 | $content['nm']['searchletter'] = false; |
346 | 352 | // switch recusive display off |
347 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
353 | + if (!$content['nm']['filter']) |
|
354 | + { |
|
355 | + $content['nm']['filter'] = ''; |
|
356 | + } |
|
348 | 357 | } |
349 | 358 | } |
350 | 359 | $view = static::get_view(); |
@@ -393,37 +402,70 @@ discard block |
||
393 | 402 | { |
394 | 403 | $tpl = new Etemplate('filemanager.index'); |
395 | 404 | |
396 | - if($msg) Framework::message($msg); |
|
405 | + if($msg) |
|
406 | + { |
|
407 | + Framework::message($msg); |
|
408 | + } |
|
397 | 409 | |
398 | 410 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
399 | 411 | { |
400 | 412 | if ($content['nm']['action']) |
401 | 413 | { |
402 | 414 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
403 | - if($msg) Framework::message($msg); |
|
415 | + if($msg) |
|
416 | + { |
|
417 | + Framework::message($msg); |
|
418 | + } |
|
404 | 419 | |
405 | 420 | // clean up after action |
406 | 421 | unset($content['nm']['selected']); |
407 | 422 | // 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 |
408 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
409 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
410 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
423 | + if (isset($content['nm']['action'])) |
|
424 | + { |
|
425 | + unset($content['nm']['action']); |
|
426 | + } |
|
427 | + if (isset($content['nm']['nm_action'])) |
|
428 | + { |
|
429 | + unset($content['nm']['nm_action']); |
|
430 | + } |
|
431 | + if (isset($content['nm_action'])) |
|
432 | + { |
|
433 | + unset($content['nm_action']); |
|
434 | + } |
|
411 | 435 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
412 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
436 | + if (isset($content['nm']['rows']['delete'])) |
|
437 | + { |
|
438 | + unset($content['nm']['rows']['delete']); |
|
439 | + } |
|
413 | 440 | } |
414 | 441 | elseif($content['nm']['rows']['delete']) |
415 | 442 | { |
416 | 443 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
417 | - if($msg) Framework::message($msg); |
|
444 | + if($msg) |
|
445 | + { |
|
446 | + Framework::message($msg); |
|
447 | + } |
|
418 | 448 | |
419 | 449 | // clean up after action |
420 | 450 | unset($content['nm']['rows']['delete']); |
421 | 451 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
422 | 452 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
423 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
424 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
425 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
426 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
453 | + if (isset($content['nm']['action'])) |
|
454 | + { |
|
455 | + unset($content['nm']['action']); |
|
456 | + } |
|
457 | + if (isset($content['nm']['nm_action'])) |
|
458 | + { |
|
459 | + unset($content['nm']['nm_action']); |
|
460 | + } |
|
461 | + if (isset($content['nm_action'])) |
|
462 | + { |
|
463 | + unset($content['nm_action']); |
|
464 | + } |
|
465 | + if (isset($content['nm']['selected'])) |
|
466 | + { |
|
467 | + unset($content['nm']['selected']); |
|
468 | + } |
|
427 | 469 | } |
428 | 470 | unset($content['nm']['rows']); |
429 | 471 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -587,9 +629,12 @@ discard block |
||
587 | 629 | foreach(Vfs::find($path) as $p) |
588 | 630 | { |
589 | 631 | $to = $dir.substr($p,$len); |
590 | - if ($to == $p) // cant copy into itself! |
|
632 | + if ($to == $p) |
|
633 | + { |
|
634 | + // cant copy into itself! |
|
591 | 635 | { |
592 | 636 | ++$errs; |
637 | + } |
|
593 | 638 | continue; |
594 | 639 | } |
595 | 640 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -644,7 +689,10 @@ discard block |
||
644 | 689 | continue; |
645 | 690 | } |
646 | 691 | } |
647 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
692 | + if ($target[0] != '/') |
|
693 | + { |
|
694 | + $target = Vfs::concat($dir, $target); |
|
695 | + } |
|
648 | 696 | if (!Vfs::stat($target)) |
649 | 697 | { |
650 | 698 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -687,10 +735,16 @@ discard block |
||
687 | 735 | switch($action) |
688 | 736 | { |
689 | 737 | case 'document': |
690 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
738 | + if (!$settings) |
|
739 | + { |
|
740 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
741 | + } |
|
691 | 742 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
692 | 743 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
693 | - if($msg) return $msg; |
|
744 | + if($msg) |
|
745 | + { |
|
746 | + return $msg; |
|
747 | + } |
|
694 | 748 | $errs = count($selected); |
695 | 749 | return false; |
696 | 750 | } |
@@ -727,7 +781,9 @@ discard block |
||
727 | 781 | unset($selected[$key]); |
728 | 782 | } |
729 | 783 | } |
730 | - if ($selected) // somethings left to delete |
|
784 | + if ($selected) |
|
785 | + { |
|
786 | + // somethings left to delete |
|
731 | 787 | { |
732 | 788 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
733 | 789 | foreach((array)$selected as $path) |
@@ -735,6 +791,7 @@ discard block |
||
735 | 791 | if (preg_match('/^\/?(home|apps|)\/*$/',$path)) |
736 | 792 | { |
737 | 793 | $errs++; |
794 | + } |
|
738 | 795 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
739 | 796 | } |
740 | 797 | } |
@@ -782,7 +839,10 @@ discard block |
||
782 | 839 | { |
783 | 840 | Api\Cache::setSession('filemanager', 'index',$query); |
784 | 841 | } |
785 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
842 | + if(!$query['path']) |
|
843 | + { |
|
844 | + $query['path'] = static::get_home_dir(); |
|
845 | + } |
|
786 | 846 | |
787 | 847 | // Change template to match selected view |
788 | 848 | if($query['view']) |
@@ -840,7 +900,10 @@ discard block |
||
840 | 900 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
841 | 901 | |
842 | 902 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
843 | - if($filter == 5) $maxdepth = 2; |
|
903 | + if($filter == 5) |
|
904 | + { |
|
905 | + $maxdepth = 2; |
|
906 | + } |
|
844 | 907 | $n = 0; |
845 | 908 | $vfs_options = array( |
846 | 909 | 'mindepth' => 1, |
@@ -893,10 +956,16 @@ discard block |
||
893 | 956 | { |
894 | 957 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
895 | 958 | $row =& $rows[$path2n[$path]]; |
896 | - if ( !is_array($props) ) continue; |
|
959 | + if ( !is_array($props) ) |
|
960 | + { |
|
961 | + continue; |
|
962 | + } |
|
897 | 963 | foreach($props as $prop) |
898 | 964 | { |
899 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
965 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
966 | + { |
|
967 | + continue; |
|
968 | + } |
|
900 | 969 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
901 | 970 | } |
902 | 971 | } |
@@ -1021,7 +1090,10 @@ discard block |
||
1021 | 1090 | if (!($dir = Vfs::dirname($path))) |
1022 | 1091 | { |
1023 | 1092 | $msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false"; |
1024 | - if ($button == 'save') $button = 'apply'; |
|
1093 | + if ($button == 'save') |
|
1094 | + { |
|
1095 | + $button = 'apply'; |
|
1096 | + } |
|
1025 | 1097 | continue; |
1026 | 1098 | } |
1027 | 1099 | $to = Vfs::concat($dir, $content['name']); |
@@ -1030,7 +1102,10 @@ discard block |
||
1030 | 1102 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
1031 | 1103 | lang('To overwrite the existing file store again.',lang($button))); |
1032 | 1104 | $content['confirm_overwrite'] = $to; |
1033 | - if ($button == 'save') $button = 'apply'; |
|
1105 | + if ($button == 'save') |
|
1106 | + { |
|
1107 | + $button = 'apply'; |
|
1108 | + } |
|
1034 | 1109 | continue; |
1035 | 1110 | } |
1036 | 1111 | if (Vfs::rename($path,$to)) |
@@ -1103,13 +1178,19 @@ discard block |
||
1103 | 1178 | } |
1104 | 1179 | if ($ok && !$failed) |
1105 | 1180 | { |
1106 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1181 | + if(!$perm_changed++) |
|
1182 | + { |
|
1183 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1184 | + } |
|
1107 | 1185 | $content['old'][$name] = $content[$name]; |
1108 | 1186 | } |
1109 | 1187 | elseif($failed) |
1110 | 1188 | { |
1111 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1189 | + if(!$perm_failed++) |
|
1190 | + { |
|
1191 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1112 | 1192 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
1193 | + } |
|
1113 | 1194 | } |
1114 | 1195 | } |
1115 | 1196 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1162,7 +1243,10 @@ discard block |
||
1162 | 1243 | } |
1163 | 1244 | } |
1164 | 1245 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
1165 | - if ($button == 'save') Framework::window_close(); |
|
1246 | + if ($button == 'save') |
|
1247 | + { |
|
1248 | + Framework::window_close(); |
|
1249 | + } |
|
1166 | 1250 | } |
1167 | 1251 | if ($content['is_link'] && !Vfs::stat($path)) |
1168 | 1252 | { |
@@ -1172,12 +1256,18 @@ discard block |
||
1172 | 1256 | $content['icon'] = Vfs::mime_icon($content['mime']); |
1173 | 1257 | $content['msg'] = $msg; |
1174 | 1258 | |
1175 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
1259 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
1260 | + { |
|
1261 | + $content['ro_uid_root'] = 'root'; |
|
1262 | + } |
|
1176 | 1263 | // only owner can change group & perms |
1177 | 1264 | if (($readonlys['gid'] = !$content['is_owner'] || |
1178 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1265 | + Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) |
|
1266 | + { |
|
1267 | + // no uid, gid or perms in oldvfs |
|
1179 | 1268 | { |
1180 | 1269 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1270 | + } |
|
1181 | 1271 | foreach($content['perms'] as $name => $value) |
1182 | 1272 | { |
1183 | 1273 | $readonlys['perms['.$name.']'] = true; |
@@ -1210,9 +1300,13 @@ discard block |
||
1210 | 1300 | 5 => lang('Display of content'), |
1211 | 1301 | 0 => lang('No access'), |
1212 | 1302 | ); |
1213 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1303 | + if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) |
|
1214 | 1304 | { |
1215 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1305 | + // backend supports eacl |
|
1306 | + { |
|
1307 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
1308 | + } |
|
1309 | + // --> switch the tab on again |
|
1216 | 1310 | foreach($content['eacl'] as &$eacl) |
1217 | 1311 | { |
1218 | 1312 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1269,10 +1363,13 @@ discard block |
||
1269 | 1363 | 'comment' => (string)$content['comment'], |
1270 | 1364 | 'mergeapp' => $content['mergeapp'] |
1271 | 1365 | ); |
1272 | - if ($cfs) foreach($cfs as $name => $data) |
|
1366 | + if ($cfs) |
|
1367 | + { |
|
1368 | + foreach($cfs as $name => $data) |
|
1273 | 1369 | { |
1274 | 1370 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1275 | 1371 | } |
1372 | + } |
|
1276 | 1373 | } |
1277 | 1374 | if (Vfs::$is_root) |
1278 | 1375 | { |
@@ -1294,7 +1391,10 @@ discard block |
||
1294 | 1391 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1295 | 1392 | |
1296 | 1393 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
1297 | - if (true) $tabs = array(); |
|
1394 | + if (true) |
|
1395 | + { |
|
1396 | + $tabs = array(); |
|
1397 | + } |
|
1298 | 1398 | |
1299 | 1399 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
1300 | 1400 | { |
@@ -1347,7 +1447,10 @@ discard block |
||
1347 | 1447 | 'files' => 0, |
1348 | 1448 | ); |
1349 | 1449 | |
1350 | - if (!isset($dir)) $dir = array_pop($selected); |
|
1450 | + if (!isset($dir)) |
|
1451 | + { |
|
1452 | + $dir = array_pop($selected); |
|
1453 | + } |
|
1351 | 1454 | |
1352 | 1455 | switch($action) |
1353 | 1456 | { |
@@ -1421,7 +1524,10 @@ discard block |
||
1421 | 1524 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
1422 | 1525 | if (Vfs::file_exists($target) && $app_dir) |
1423 | 1526 | { |
1424 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
1527 | + if (!Vfs::file_exists($app_dir)) |
|
1528 | + { |
|
1529 | + Vfs::mkdir($app_dir); |
|
1530 | + } |
|
1425 | 1531 | error_log("Symlinking $target to $app_dir"); |
1426 | 1532 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
1427 | 1533 | } |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | if (!static::$views_init) |
81 | 81 | { |
82 | 82 | // translate our labels |
83 | - foreach(static::$views as &$label) |
|
83 | + foreach (static::$views as &$label) |
|
84 | 84 | { |
85 | 85 | $label = lang($label); |
86 | 86 | } |
87 | 87 | // search for plugins with additional filemanager views |
88 | - foreach(Api\Hooks::process('filemanager_views') as $views) |
|
88 | + foreach (Api\Hooks::process('filemanager_views') as $views) |
|
89 | 89 | { |
90 | 90 | if (is_array($views)) static::$views += $views; |
91 | 91 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function get_view() |
103 | 103 | { |
104 | - $view =& Api\Cache::getSession('filemanager', 'view'); |
|
104 | + $view = & Api\Cache::getSession('filemanager', 'view'); |
|
105 | 105 | if (isset($_GET['view'])) |
106 | 106 | { |
107 | 107 | $view = $_GET['view']; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | 'open' => array( |
126 | 126 | 'caption' => lang('Open'), |
127 | 127 | 'icon' => '', |
128 | - 'group' => $group=1, |
|
128 | + 'group' => $group = 1, |
|
129 | 129 | 'allowOnMultiple' => false, |
130 | 130 | 'onExecute' => 'javaScript:app.filemanager.open', |
131 | 131 | 'default' => true |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'caption' => lang('Edit settings'), |
151 | 151 | 'group' => $group, |
152 | 152 | 'allowOnMultiple' => false, |
153 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs', |
|
153 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.filemanager.viewEntry' : 'javaScript:app.filemanager.editprefs', |
|
154 | 154 | 'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet')) |
155 | 155 | ), |
156 | 156 | 'mkdir' => array( |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | ), |
180 | 180 | // DRAG and DROP events |
181 | 181 | 'file_drag' => array( |
182 | - 'dragType' => array('file','link'), |
|
182 | + 'dragType' => array('file', 'link'), |
|
183 | 183 | 'type' => 'drag', |
184 | 184 | 'onExecute' => 'javaScript:app.filemanager.drag' |
185 | 185 | ), |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | else |
220 | 220 | { |
221 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
221 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
222 | 222 | { |
223 | 223 | $actions['mail']['children']['mail_'.$mode] = array( |
224 | 224 | 'caption' => $data['label'], |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string merge application or NULL if no property found |
242 | 242 | */ |
243 | - private static function get_mergeapp($path, $scope='self') |
|
243 | + private static function get_mergeapp($path, $scope = 'self') |
|
244 | 244 | { |
245 | 245 | $app = null; |
246 | - switch($scope) |
|
246 | + switch ($scope) |
|
247 | 247 | { |
248 | 248 | case 'self': |
249 | 249 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | case 'parents': |
253 | 253 | // search for props in parent directories |
254 | 254 | $currentpath = $path; |
255 | - while($dir = Vfs::dirname($currentpath)) |
|
255 | + while ($dir = Vfs::dirname($currentpath)) |
|
256 | 256 | { |
257 | 257 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
258 | - if(!empty($props)) |
|
258 | + if (!empty($props)) |
|
259 | 259 | { |
260 | 260 | // found prop in parent directory |
261 | 261 | return $app = $props[0]['val']; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param array $content |
275 | 275 | * @param string $msg |
276 | 276 | */ |
277 | - function index(array $content=null,$msg=null) |
|
277 | + function index(array $content = null, $msg = null) |
|
278 | 278 | { |
279 | 279 | if (!is_array($content)) |
280 | 280 | { |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | if (!is_array($content['nm'])) |
285 | 285 | { |
286 | 286 | $content['nm'] = array( |
287 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
288 | - 'filter' => '', // current dir only |
|
289 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
290 | - 'no_cat' => True, // I disable the cat-selectbox |
|
291 | - 'lettersearch' => True, // I show a lettersearch |
|
292 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
293 | - 'start' => 0, // IO position in list |
|
294 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
295 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
296 | - '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 |
|
287 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
288 | + 'filter' => '', // current dir only |
|
289 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
290 | + 'no_cat' => True, // I disable the cat-selectbox |
|
291 | + 'lettersearch' => True, // I show a lettersearch |
|
292 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
293 | + 'start' => 0, // IO position in list |
|
294 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
295 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
296 | + '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 |
|
297 | 297 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
298 | 298 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
299 | 299 | 'actions' => static::get_actions(), |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'is_parent' => 'mime', |
304 | 304 | 'is_parent_value'=> Vfs::DIR_MIME_TYPE, |
305 | 305 | 'favorites' => true, |
306 | - 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
306 | + 'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
307 | 307 | ); |
308 | 308 | $content['nm']['path'] = static::get_home_dir(); |
309 | 309 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
326 | 326 | { |
327 | - switch($path) |
|
327 | + switch ($path) |
|
328 | 328 | { |
329 | 329 | case '..': |
330 | 330 | $path = Vfs::dirname($content['nm']['path']); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $path = static::get_home_dir(); |
334 | 334 | break; |
335 | 335 | } |
336 | - if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
336 | + if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
337 | 337 | { |
338 | 338 | $content['nm']['path'] = $path; |
339 | 339 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | $view = static::get_view(); |
351 | 351 | |
352 | - call_user_func($view,$content,$msg); |
|
352 | + call_user_func($view, $content, $msg); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
363 | 363 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
364 | 364 | */ |
365 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
365 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
366 | 366 | { |
367 | 367 | if (!$user) |
368 | 368 | { |
@@ -371,15 +371,15 @@ discard block |
||
371 | 371 | else |
372 | 372 | { |
373 | 373 | // config user & password |
374 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
374 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
375 | 375 | // or vfs root user from setup >> configuration |
376 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
377 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
376 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
377 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
378 | 378 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
379 | 379 | } |
380 | 380 | //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)); |
381 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
382 | - Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
381 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
382 | + Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
383 | 383 | return Vfs::$is_root; |
384 | 384 | } |
385 | 385 | |
@@ -389,18 +389,18 @@ discard block |
||
389 | 389 | * @param array $content |
390 | 390 | * @param string $msg |
391 | 391 | */ |
392 | - function listview(array $content=null,$msg=null) |
|
392 | + function listview(array $content = null, $msg = null) |
|
393 | 393 | { |
394 | 394 | $tpl = new Etemplate('filemanager.index'); |
395 | 395 | |
396 | - if($msg) Framework::message($msg); |
|
396 | + if ($msg) Framework::message($msg); |
|
397 | 397 | |
398 | 398 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
399 | 399 | { |
400 | 400 | if ($content['nm']['action']) |
401 | 401 | { |
402 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
403 | - if($msg) Framework::message($msg); |
|
402 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
403 | + if ($msg) Framework::message($msg); |
|
404 | 404 | |
405 | 405 | // clean up after action |
406 | 406 | unset($content['nm']['selected']); |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
412 | 412 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
413 | 413 | } |
414 | - elseif($content['nm']['rows']['delete']) |
|
414 | + elseif ($content['nm']['rows']['delete']) |
|
415 | 415 | { |
416 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
417 | - if($msg) Framework::message($msg); |
|
416 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
417 | + if ($msg) Framework::message($msg); |
|
418 | 418 | |
419 | 419 | // clean up after action |
420 | 420 | unset($content['nm']['rows']['delete']); |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
427 | 427 | } |
428 | 428 | unset($content['nm']['rows']); |
429 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
429 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // be tolerant with (in previous versions) not correct urlencoded pathes |
433 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
433 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
434 | 434 | { |
435 | 435 | $content['nm']['path'] = urldecode($content['nm']['path']); |
436 | 436 | } |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | list($button) = each($content['button']); |
442 | 442 | unset($content['button']); |
443 | 443 | } |
444 | - switch($button) |
|
444 | + switch ($button) |
|
445 | 445 | { |
446 | 446 | case 'upload': |
447 | 447 | if (!$content['upload']) |
448 | 448 | { |
449 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
449 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
450 | 450 | break; |
451 | 451 | } |
452 | 452 | $upload_success = $upload_failure = array(); |
453 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
453 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
454 | 454 | { |
455 | 455 | // encode chars which special meaning in url/vfs (some like / get removed!) |
456 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
456 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
457 | 457 | if ($upload && |
458 | 458 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
459 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
459 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
460 | 460 | { |
461 | 461 | $upload_success[] = $upload['name']; |
462 | 462 | } |
@@ -468,12 +468,11 @@ discard block |
||
468 | 468 | $content['nm']['msg'] = ''; |
469 | 469 | if ($upload_success) |
470 | 470 | { |
471 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
472 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
471 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
473 | 472 | } |
474 | 473 | if ($upload_failure) |
475 | 474 | { |
476 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
475 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
477 | 476 | } |
478 | 477 | break; |
479 | 478 | } |
@@ -494,16 +493,16 @@ discard block |
||
494 | 493 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
495 | 494 | } |
496 | 495 | // Set view button to match current settings |
497 | - if($content['nm']['view'] == 'tile') |
|
496 | + if ($content['nm']['view'] == 'tile') |
|
498 | 497 | { |
499 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
500 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
498 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
499 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
501 | 500 | } |
502 | 501 | // if initial load is done via GET request (idots template or share.php) |
503 | 502 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
504 | 503 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
505 | 504 | |
506 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
505 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
507 | 506 | } |
508 | 507 | |
509 | 508 | /** |
@@ -539,7 +538,7 @@ discard block |
||
539 | 538 | * @param int &$files=null on return number of files deleted |
540 | 539 | * @return string success or failure message displayed to the user |
541 | 540 | */ |
542 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
541 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
543 | 542 | { |
544 | 543 | if (!count($selected)) |
545 | 544 | { |
@@ -547,20 +546,20 @@ discard block |
||
547 | 546 | } |
548 | 547 | $errs = $dirs = $files = 0; |
549 | 548 | |
550 | - switch($action) |
|
549 | + switch ($action) |
|
551 | 550 | { |
552 | 551 | |
553 | 552 | case 'delete': |
554 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
553 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
555 | 554 | |
556 | 555 | case 'mail': |
557 | 556 | case 'copy': |
558 | - foreach($selected as $path) |
|
557 | + foreach ($selected as $path) |
|
559 | 558 | { |
560 | 559 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
561 | 560 | { |
562 | 561 | // Support for dropping mail in filemanager - Pass mail back to mail app |
563 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
562 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
564 | 563 | { |
565 | 564 | ++$files; |
566 | 565 | } |
@@ -571,8 +570,8 @@ discard block |
||
571 | 570 | } |
572 | 571 | elseif (!Vfs::is_dir($path)) |
573 | 572 | { |
574 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
575 | - if ($path != $to && Vfs::copy($path,$to)) |
|
573 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
574 | + if ($path != $to && Vfs::copy($path, $to)) |
|
576 | 575 | { |
577 | 576 | ++$files; |
578 | 577 | } |
@@ -584,19 +583,19 @@ discard block |
||
584 | 583 | else |
585 | 584 | { |
586 | 585 | $len = strlen(dirname($path)); |
587 | - foreach(Vfs::find($path) as $p) |
|
586 | + foreach (Vfs::find($path) as $p) |
|
588 | 587 | { |
589 | - $to = $dir.substr($p,$len); |
|
588 | + $to = $dir.substr($p, $len); |
|
590 | 589 | if ($to == $p) // cant copy into itself! |
591 | 590 | { |
592 | 591 | ++$errs; |
593 | 592 | continue; |
594 | 593 | } |
595 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
594 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
596 | 595 | { |
597 | 596 | ++$dirs; |
598 | 597 | } |
599 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
598 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
600 | 599 | { |
601 | 600 | ++$files; |
602 | 601 | } |
@@ -609,15 +608,15 @@ discard block |
||
609 | 608 | } |
610 | 609 | if ($errs) |
611 | 610 | { |
612 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
611 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
613 | 612 | } |
614 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
613 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
615 | 614 | |
616 | 615 | case 'move': |
617 | - foreach($selected as $path) |
|
616 | + foreach ($selected as $path) |
|
618 | 617 | { |
619 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
620 | - if ($path != $to && Vfs::rename($path,$to)) |
|
618 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
619 | + if ($path != $to && Vfs::rename($path, $to)) |
|
621 | 620 | { |
622 | 621 | ++$files; |
623 | 622 | } |
@@ -628,17 +627,17 @@ discard block |
||
628 | 627 | } |
629 | 628 | if ($errs) |
630 | 629 | { |
631 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
630 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
632 | 631 | } |
633 | - return lang('%1 files moved.',$files); |
|
632 | + return lang('%1 files moved.', $files); |
|
634 | 633 | |
635 | 634 | case 'symlink': // symlink given files to $dir |
636 | - foreach((array)$selected as $target) |
|
635 | + foreach ((array)$selected as $target) |
|
637 | 636 | { |
638 | 637 | $link = Vfs::concat($dir, Vfs::basename($target)); |
639 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
638 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
640 | 639 | { |
641 | - if(!$ok) |
|
640 | + if (!$ok) |
|
642 | 641 | { |
643 | 642 | $errs++; |
644 | 643 | continue; |
@@ -660,15 +659,14 @@ discard block |
||
660 | 659 | } |
661 | 660 | if (count((array)$selected) == 1) |
662 | 661 | { |
663 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
664 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
662 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
665 | 663 | } |
666 | 664 | $ret = lang('%1 elements linked.', $files); |
667 | 665 | if ($errs) |
668 | 666 | { |
669 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
667 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
670 | 668 | } |
671 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
669 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
672 | 670 | |
673 | 671 | case 'createdir': |
674 | 672 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -684,13 +682,13 @@ discard block |
||
684 | 682 | |
685 | 683 | default: |
686 | 684 | list($action, $settings) = explode('_', $action, 2); |
687 | - switch($action) |
|
685 | + switch ($action) |
|
688 | 686 | { |
689 | 687 | case 'document': |
690 | 688 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
691 | 689 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
692 | 690 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
693 | - if($msg) return $msg; |
|
691 | + if ($msg) return $msg; |
|
694 | 692 | $errs = count($selected); |
695 | 693 | return false; |
696 | 694 | } |
@@ -707,12 +705,12 @@ discard block |
||
707 | 705 | * @param int &$files=null on return number of files deleted |
708 | 706 | * @return string |
709 | 707 | */ |
710 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
708 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
711 | 709 | { |
712 | 710 | $dirs = $files = $errs = 0; |
713 | 711 | // we first delete all selected links (and files) |
714 | 712 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
715 | - foreach($selected as $key => $path) |
|
713 | + foreach ($selected as $key => $path) |
|
716 | 714 | { |
717 | 715 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
718 | 716 | { |
@@ -730,21 +728,21 @@ discard block |
||
730 | 728 | if ($selected) // somethings left to delete |
731 | 729 | { |
732 | 730 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
733 | - foreach((array)$selected as $path) |
|
731 | + foreach ((array)$selected as $path) |
|
734 | 732 | { |
735 | - if (preg_match('/^\/?(home|apps|)\/*$/',$path)) |
|
733 | + if (preg_match('/^\/?(home|apps|)\/*$/', $path)) |
|
736 | 734 | { |
737 | 735 | $errs++; |
738 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
736 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
739 | 737 | } |
740 | 738 | } |
741 | 739 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
742 | 740 | // - depth=true to get first the files and then the dir containing it |
743 | 741 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
744 | 742 | // - show-deleted=false to not (finally) deleted versioned files |
745 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
743 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
746 | 744 | { |
747 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
745 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
748 | 746 | { |
749 | 747 | ++$dirs; |
750 | 748 | } |
@@ -760,13 +758,13 @@ discard block |
||
760 | 758 | } |
761 | 759 | if ($errs) |
762 | 760 | { |
763 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
761 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
764 | 762 | } |
765 | 763 | if ($dirs) |
766 | 764 | { |
767 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
765 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
768 | 766 | } |
769 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
767 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
770 | 768 | } |
771 | 769 | |
772 | 770 | /** |
@@ -780,37 +778,37 @@ discard block |
||
780 | 778 | // do NOT store query, if hierarchical data / children are requested |
781 | 779 | if (!$query['csv_export']) |
782 | 780 | { |
783 | - Api\Cache::setSession('filemanager', 'index',$query); |
|
781 | + Api\Cache::setSession('filemanager', 'index', $query); |
|
784 | 782 | } |
785 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
783 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
786 | 784 | |
787 | 785 | // Change template to match selected view |
788 | - if($query['view']) |
|
786 | + if ($query['view']) |
|
789 | 787 | { |
790 | 788 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
791 | 789 | |
792 | 790 | // Store as preference but only for index, not home |
793 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
791 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
794 | 792 | { |
795 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
793 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
796 | 794 | $GLOBALS['egw']->preferences->save_repository(); |
797 | 795 | } |
798 | 796 | } |
799 | 797 | // be tolerant with (in previous versions) not correct urlencoded pathes |
800 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
798 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
801 | 799 | { |
802 | 800 | $query['path'] = urldecode($query['path']); |
803 | 801 | } |
804 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
802 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
805 | 803 | { |
806 | 804 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
807 | 805 | if ($query['path'] != ($path = static::get_home_dir())) |
808 | 806 | { |
809 | 807 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
810 | 808 | // an appropriate message |
811 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
809 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
812 | 810 | 'path' => $path, |
813 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
811 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
814 | 812 | 'ajax' => 'true' |
815 | 813 | )); |
816 | 814 | } |
@@ -818,35 +816,35 @@ discard block |
||
818 | 816 | return 0; |
819 | 817 | } |
820 | 818 | $rows = $dir_is_writable = array(); |
821 | - if($query['searchletter'] && !empty($query['search'])) |
|
819 | + if ($query['searchletter'] && !empty($query['search'])) |
|
822 | 820 | { |
823 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
821 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
824 | 822 | if ($query['searchletter'] == strtolower($query['search'][0])) |
825 | 823 | { |
826 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
827 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
824 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
825 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
828 | 826 | } |
829 | 827 | } |
830 | 828 | elseif ($query['searchletter']) |
831 | 829 | { |
832 | 830 | $namefilter = '/^'.$query['searchletter'].'/i'; |
833 | 831 | } |
834 | - elseif(!empty($query['search'])) |
|
832 | + elseif (!empty($query['search'])) |
|
835 | 833 | { |
836 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
834 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
837 | 835 | } |
838 | 836 | |
839 | 837 | // Re-map so 'No filters' favorite ('') is depth 1 |
840 | 838 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
841 | 839 | |
842 | 840 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
843 | - if($filter == 5) $maxdepth = 2; |
|
841 | + if ($filter == 5) $maxdepth = 2; |
|
844 | 842 | $n = 0; |
845 | 843 | $vfs_options = array( |
846 | 844 | 'mindepth' => 1, |
847 | 845 | 'maxdepth' => $maxdepth, |
848 | 846 | 'dirsontop' => $filter <= 1, |
849 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
847 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
850 | 848 | 'order' => $query['order'], 'sort' => $query['sort'], |
851 | 849 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
852 | 850 | 'need_mime' => true, |
@@ -854,11 +852,11 @@ discard block |
||
854 | 852 | 'hidden' => $filter == 3, |
855 | 853 | 'follow' => $filter == 5, |
856 | 854 | ); |
857 | - if($query['col_filter']['mime']) |
|
855 | + if ($query['col_filter']['mime']) |
|
858 | 856 | { |
859 | 857 | $vfs_options['mime'] = $query['col_filter']['mime']; |
860 | 858 | } |
861 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
859 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
862 | 860 | { |
863 | 861 | //echo $path; _debug_array($row); |
864 | 862 | |
@@ -872,32 +870,32 @@ discard block |
||
872 | 870 | $row['class'] = 'isDir'; |
873 | 871 | } |
874 | 872 | $row['download_url'] = Vfs::download_url($path); |
875 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
873 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
876 | 874 | |
877 | 875 | $rows[++$n] = $row; |
878 | 876 | $path2n[$path] = $n; |
879 | 877 | } |
880 | 878 | // query comments and cf's for the displayed rows |
881 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
879 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
882 | 880 | |
883 | 881 | // Always include comment in tiles |
884 | - if($query['view'] == 'tile') |
|
882 | + if ($query['view'] == 'tile') |
|
885 | 883 | { |
886 | 884 | $cols_to_show[] = 'comment'; |
887 | 885 | } |
888 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
889 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
886 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
887 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
890 | 888 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
891 | 889 | { |
892 | - foreach($path2props as $path => $props) |
|
890 | + foreach ($path2props as $path => $props) |
|
893 | 891 | { |
894 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
895 | - $row =& $rows[$path2n[$path]]; |
|
896 | - if ( !is_array($props) ) continue; |
|
897 | - foreach($props as $prop) |
|
892 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
893 | + $row = & $rows[$path2n[$path]]; |
|
894 | + if (!is_array($props)) continue; |
|
895 | + foreach ($props as $prop) |
|
898 | 896 | { |
899 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
900 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
897 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
898 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
901 | 899 | } |
902 | 900 | } |
903 | 901 | } |
@@ -909,7 +907,7 @@ discard block |
||
909 | 907 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
910 | 908 | { |
911 | 909 | // we need our app.css file |
912 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
910 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
913 | 911 | { |
914 | 912 | $css_file = '/filemanager/templates/default/app.css'; |
915 | 913 | } |
@@ -925,7 +923,7 @@ discard block |
||
925 | 923 | * @param array $content |
926 | 924 | * @param string $msg |
927 | 925 | */ |
928 | - function file(array $content=null,$msg='') |
|
926 | + function file(array $content = null, $msg = '') |
|
929 | 927 | { |
930 | 928 | $tpl = new Etemplate('filemanager.file'); |
931 | 929 | |
@@ -935,9 +933,9 @@ discard block |
||
935 | 933 | { |
936 | 934 | $msg .= $_GET['msg']; |
937 | 935 | } |
938 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
936 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
939 | 937 | // actions enclose pathes containing comma with " |
940 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
938 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
941 | 939 | !($stat = Vfs::lstat($path))) |
942 | 940 | { |
943 | 941 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -950,10 +948,10 @@ discard block |
||
950 | 948 | $content['path'] = $path; |
951 | 949 | $content['hsize'] = Vfs::hsize($stat['size']); |
952 | 950 | $content['mime'] = Vfs::mime_content_type($path); |
953 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
951 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
954 | 952 | if (($props = Vfs::propfind($path))) |
955 | 953 | { |
956 | - foreach($props as $prop) |
|
954 | + foreach ($props as $prop) |
|
957 | 955 | { |
958 | 956 | $content[$prop['name']] = $prop['val']; |
959 | 957 | } |
@@ -966,9 +964,9 @@ discard block |
||
966 | 964 | $content['tabs'] = $_GET['tabs']; |
967 | 965 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
968 | 966 | { |
969 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
967 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
970 | 968 | $mask = 6; |
971 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
969 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
972 | 970 | { |
973 | 971 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
974 | 972 | } |
@@ -978,19 +976,19 @@ discard block |
||
978 | 976 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
979 | 977 | $mask = 7; |
980 | 978 | } |
981 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
979 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
982 | 980 | { |
983 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
981 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
984 | 982 | } |
985 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
983 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
986 | 984 | } |
987 | 985 | else |
988 | 986 | { |
989 | 987 | //_debug_array($content); |
990 | - $path =& $content['path']; |
|
988 | + $path = & $content['path']; |
|
991 | 989 | |
992 | 990 | list($button) = @each($content['button']); unset($content['button']); |
993 | - if(!$button && $content['sudo']) |
|
991 | + if (!$button && $content['sudo']) |
|
994 | 992 | { |
995 | 993 | // Button to stop sudo is not in button namespace |
996 | 994 | $button = 'sudo'; |
@@ -999,21 +997,21 @@ discard block |
||
999 | 997 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
1000 | 998 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
1001 | 999 | { |
1002 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
1000 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
1003 | 1001 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
1004 | 1002 | lang('Wrong username or password!') : lang('Root access stopped.')); |
1005 | 1003 | unset($content['sudo']); |
1006 | 1004 | $content['is_owner'] = Vfs::has_owner_rights($path); |
1007 | 1005 | } |
1008 | - if (in_array($button,array('save','apply'))) |
|
1006 | + if (in_array($button, array('save', 'apply'))) |
|
1009 | 1007 | { |
1010 | 1008 | $props = array(); |
1011 | 1009 | $perm_changed = $perm_failed = 0; |
1012 | - foreach($content['old'] as $name => $old_value) |
|
1010 | + foreach ($content['old'] as $name => $old_value) |
|
1013 | 1011 | { |
1014 | 1012 | if (isset($content[$name]) && ($old_value != $content[$name] || |
1015 | 1013 | // do not check for modification, if modify_subs is checked! |
1016 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
1014 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
1017 | 1015 | ($name != 'uid' || Vfs::$is_root)) |
1018 | 1016 | { |
1019 | 1017 | if ($name == 'name') |
@@ -1027,23 +1025,23 @@ discard block |
||
1027 | 1025 | $to = Vfs::concat($dir, $content['name']); |
1028 | 1026 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
1029 | 1027 | { |
1030 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
1031 | - lang('To overwrite the existing file store again.',lang($button))); |
|
1028 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
1029 | + lang('To overwrite the existing file store again.', lang($button))); |
|
1032 | 1030 | $content['confirm_overwrite'] = $to; |
1033 | 1031 | if ($button == 'save') $button = 'apply'; |
1034 | 1032 | continue; |
1035 | 1033 | } |
1036 | - if (Vfs::rename($path,$to)) |
|
1034 | + if (Vfs::rename($path, $to)) |
|
1037 | 1035 | { |
1038 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1036 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1039 | 1037 | $content['old']['name'] = $content[$name]; |
1040 | 1038 | $path = $to; |
1041 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1042 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1039 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1040 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1043 | 1041 | } |
1044 | 1042 | else |
1045 | 1043 | { |
1046 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1044 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1047 | 1045 | if (Vfs::deny_script($to)) |
1048 | 1046 | { |
1049 | 1047 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1063,7 +1061,7 @@ discard block |
||
1063 | 1061 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
1064 | 1062 | ), |
1065 | 1063 | ); |
1066 | - if (Vfs::proppatch($path,$mergeprop)) |
|
1064 | + if (Vfs::proppatch($path, $mergeprop)) |
|
1067 | 1065 | { |
1068 | 1066 | $content['old'][$name] = $content[$name]; |
1069 | 1067 | $msg .= lang('Setting for document merge saved.'); |
@@ -1075,22 +1073,22 @@ discard block |
||
1075 | 1073 | } |
1076 | 1074 | else |
1077 | 1075 | { |
1078 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
1079 | - $cmd = array('egw_vfs',$name2cmd[$name]); |
|
1076 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
1077 | + $cmd = array('egw_vfs', $name2cmd[$name]); |
|
1080 | 1078 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
1081 | 1079 | if ($content['modify_subs']) |
1082 | 1080 | { |
1083 | 1081 | if ($name == 'perms') |
1084 | 1082 | { |
1085 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
1086 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
1083 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
1084 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
1087 | 1085 | } |
1088 | 1086 | else |
1089 | 1087 | { |
1090 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
1088 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
1091 | 1089 | } |
1092 | 1090 | $ok = $failed = 0; |
1093 | - foreach($changed as &$r) |
|
1091 | + foreach ($changed as &$r) |
|
1094 | 1092 | { |
1095 | 1093 | if ($r) |
1096 | 1094 | { |
@@ -1103,32 +1101,32 @@ discard block |
||
1103 | 1101 | } |
1104 | 1102 | if ($ok && !$failed) |
1105 | 1103 | { |
1106 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1104 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
1107 | 1105 | $content['old'][$name] = $content[$name]; |
1108 | 1106 | } |
1109 | - elseif($failed) |
|
1107 | + elseif ($failed) |
|
1110 | 1108 | { |
1111 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1112 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
1109 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
1110 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
1113 | 1111 | } |
1114 | 1112 | } |
1115 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
1113 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
1116 | 1114 | { |
1117 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
1115 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
1118 | 1116 | $content['old'][$name] = $content[$name]; |
1119 | 1117 | } |
1120 | 1118 | else |
1121 | 1119 | { |
1122 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
1120 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
1123 | 1121 | } |
1124 | 1122 | } |
1125 | 1123 | } |
1126 | 1124 | } |
1127 | 1125 | if ($props) |
1128 | 1126 | { |
1129 | - if (Vfs::proppatch($path,$props)) |
|
1127 | + if (Vfs::proppatch($path, $props)) |
|
1130 | 1128 | { |
1131 | - foreach($props as $prop) |
|
1129 | + foreach ($props as $prop) |
|
1132 | 1130 | { |
1133 | 1131 | $content['old'][$prop['name']] = $prop['val']; |
1134 | 1132 | } |
@@ -1145,8 +1143,8 @@ discard block |
||
1145 | 1143 | if ($content['eacl']['delete']) |
1146 | 1144 | { |
1147 | 1145 | list($ino_owner) = each($content['eacl']['delete']); |
1148 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
1149 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1146 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
1147 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1150 | 1148 | } |
1151 | 1149 | elseif ($button == 'eacl') |
1152 | 1150 | { |
@@ -1156,7 +1154,7 @@ discard block |
||
1156 | 1154 | } |
1157 | 1155 | else |
1158 | 1156 | { |
1159 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
1157 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
1160 | 1158 | lang('ACL added.') : lang('Error adding the ACL!'); |
1161 | 1159 | } |
1162 | 1160 | } |
@@ -1166,7 +1164,7 @@ discard block |
||
1166 | 1164 | } |
1167 | 1165 | if ($content['is_link'] && !Vfs::stat($path)) |
1168 | 1166 | { |
1169 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
1167 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
1170 | 1168 | } |
1171 | 1169 | $content['link'] = Egw::link(Vfs::download_url($path)); |
1172 | 1170 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1175,10 +1173,10 @@ discard block |
||
1175 | 1173 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
1176 | 1174 | // only owner can change group & perms |
1177 | 1175 | if (($readonlys['gid'] = !$content['is_owner'] || |
1178 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1176 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1179 | 1177 | { |
1180 | 1178 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1181 | - foreach($content['perms'] as $name => $value) |
|
1179 | + foreach ($content['perms'] as $name => $value) |
|
1182 | 1180 | { |
1183 | 1181 | $readonlys['perms['.$name.']'] = true; |
1184 | 1182 | } |
@@ -1196,37 +1194,37 @@ discard block |
||
1196 | 1194 | } |
1197 | 1195 | elseif (!Vfs::is_writable($path)) |
1198 | 1196 | { |
1199 | - foreach($cfs as $name => $data) |
|
1197 | + foreach ($cfs as $name => $data) |
|
1200 | 1198 | { |
1201 | 1199 | $readonlys['#'.$name] = true; |
1202 | 1200 | } |
1203 | 1201 | } |
1204 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1202 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1205 | 1203 | if ($content['is_dir']) |
1206 | 1204 | { |
1207 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1208 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1205 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1206 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1209 | 1207 | 7 => lang('Display and modification of content'), |
1210 | 1208 | 5 => lang('Display of content'), |
1211 | 1209 | 0 => lang('No access'), |
1212 | 1210 | ); |
1213 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1211 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1214 | 1212 | { |
1215 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1216 | - foreach($content['eacl'] as &$eacl) |
|
1213 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1214 | + foreach ($content['eacl'] as &$eacl) |
|
1217 | 1215 | { |
1218 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
1216 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
1219 | 1217 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
1220 | 1218 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
1221 | 1219 | } |
1222 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
1220 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
1223 | 1221 | $content['eacl']['owner'] = 0; |
1224 | 1222 | $content['eacl']['rights'] = 5; |
1225 | 1223 | } |
1226 | 1224 | } |
1227 | 1225 | else |
1228 | 1226 | { |
1229 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1227 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1230 | 1228 | 6 => lang('Read & write access'), |
1231 | 1229 | 4 => lang('Read access only'), |
1232 | 1230 | 0 => lang('No access'), |
@@ -1236,11 +1234,11 @@ discard block |
||
1236 | 1234 | // mergeapp |
1237 | 1235 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
1238 | 1236 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
1239 | - if(!empty($content['mergeapp'])) |
|
1237 | + if (!empty($content['mergeapp'])) |
|
1240 | 1238 | { |
1241 | 1239 | $content['mergeapp_effective'] = $content['mergeapp']; |
1242 | 1240 | } |
1243 | - elseif(!empty($content['mergeapp_parent'])) |
|
1241 | + elseif (!empty($content['mergeapp_parent'])) |
|
1244 | 1242 | { |
1245 | 1243 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
1246 | 1244 | } |
@@ -1252,7 +1250,7 @@ discard block |
||
1252 | 1250 | $mergeapp_list = Link::app_list('merge'); |
1253 | 1251 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
1254 | 1252 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
1255 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
1253 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
1256 | 1254 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
1257 | 1255 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
1258 | 1256 | // mergeapp other gui options |
@@ -1269,7 +1267,7 @@ discard block |
||
1269 | 1267 | 'comment' => (string)$content['comment'], |
1270 | 1268 | 'mergeapp' => $content['mergeapp'] |
1271 | 1269 | ); |
1272 | - if ($cfs) foreach($cfs as $name => $data) |
|
1270 | + if ($cfs) foreach ($cfs as $name => $data) |
|
1273 | 1271 | { |
1274 | 1272 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1275 | 1273 | } |
@@ -1277,26 +1275,26 @@ discard block |
||
1277 | 1275 | if (Vfs::$is_root) |
1278 | 1276 | { |
1279 | 1277 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
1280 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
1278 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
1281 | 1279 | // Need a more complex submit because button type is buttononly, which doesn't submit |
1282 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
1280 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
1283 | 1281 | |
1284 | 1282 | } |
1285 | 1283 | elseif ($button == 'sudo') |
1286 | 1284 | { |
1287 | 1285 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
1288 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
1289 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
1286 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
1287 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
1290 | 1288 | } |
1291 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
1289 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
1292 | 1290 | { |
1293 | 1291 | // add to existing tabs in template |
1294 | 1292 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1295 | 1293 | |
1296 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
1294 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
1297 | 1295 | if (true) $tabs = array(); |
1298 | 1296 | |
1299 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1297 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1300 | 1298 | { |
1301 | 1299 | $tabs[] = array( |
1302 | 1300 | 'label' => $extra_tab['label'], |
@@ -1319,7 +1317,7 @@ discard block |
||
1319 | 1317 | Framework::window_focus(); |
1320 | 1318 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
1321 | 1319 | |
1322 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
1320 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
1323 | 1321 | } |
1324 | 1322 | |
1325 | 1323 | /** |
@@ -1330,7 +1328,7 @@ discard block |
||
1330 | 1328 | * @param string $dir=null current directory |
1331 | 1329 | * @see static::action() |
1332 | 1330 | */ |
1333 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
1331 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
1334 | 1332 | { |
1335 | 1333 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
1336 | 1334 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1349,15 +1347,15 @@ discard block |
||
1349 | 1347 | |
1350 | 1348 | if (!isset($dir)) $dir = array_pop($selected); |
1351 | 1349 | |
1352 | - switch($action) |
|
1350 | + switch ($action) |
|
1353 | 1351 | { |
1354 | 1352 | case 'upload': |
1355 | 1353 | $script_error = 0; |
1356 | - foreach($selected as $tmp_name => &$data) |
|
1354 | + foreach ($selected as $tmp_name => &$data) |
|
1357 | 1355 | { |
1358 | 1356 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
1359 | 1357 | |
1360 | - if(Vfs::deny_script($path)) |
|
1358 | + if (Vfs::deny_script($path)) |
|
1361 | 1359 | { |
1362 | 1360 | if (!isset($script_error)) |
1363 | 1361 | { |
@@ -1379,7 +1377,7 @@ discard block |
||
1379 | 1377 | { |
1380 | 1378 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
1381 | 1379 | { |
1382 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
1380 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
1383 | 1381 | } |
1384 | 1382 | else |
1385 | 1383 | { |
@@ -1414,16 +1412,16 @@ discard block |
||
1414 | 1412 | case 'link': |
1415 | 1413 | // First upload |
1416 | 1414 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
1417 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
1415 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
1418 | 1416 | |
1419 | - foreach($arr['uploaded'] as $file) |
|
1417 | + foreach ($arr['uploaded'] as $file) |
|
1420 | 1418 | { |
1421 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
1419 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
1422 | 1420 | if (Vfs::file_exists($target) && $app_dir) |
1423 | 1421 | { |
1424 | 1422 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
1425 | 1423 | error_log("Symlinking $target to $app_dir"); |
1426 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
1424 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
1427 | 1425 | } |
1428 | 1426 | } |
1429 | 1427 | // Must return to avoid adding to $response again |
@@ -1445,7 +1443,7 @@ discard block |
||
1445 | 1443 | */ |
1446 | 1444 | private function perms2mode(array $perms) |
1447 | 1445 | { |
1448 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
1446 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
1449 | 1447 | if ($mode['executable']) |
1450 | 1448 | { |
1451 | 1449 | $mode |= 0111; |
@@ -198,7 +198,7 @@ |
||
198 | 198 | /** |
199 | 199 | * This portlet accepts files and links |
200 | 200 | * |
201 | - * @return boolean|String[] |
|
201 | + * @return string[] |
|
202 | 202 | */ |
203 | 203 | public function accept_drop() |
204 | 204 | { |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | { |
43 | 43 | if (false) parent::__construct(); |
44 | 44 | |
45 | - if(!is_array($context['list'])) $context['list'] = array(); |
|
45 | + if (!is_array($context['list'])) $context['list'] = array(); |
|
46 | 46 | |
47 | 47 | // Process dropped data (Should be GUIDs) into something useable |
48 | - if($context['dropped_data']) |
|
48 | + if ($context['dropped_data']) |
|
49 | 49 | { |
50 | - foreach((Array)$context['dropped_data'] as $dropped) |
|
50 | + foreach ((Array)$context['dropped_data'] as $dropped) |
|
51 | 51 | { |
52 | 52 | $add = array(); |
53 | 53 | list($add['app'], $add['id']) = explode('::', $dropped, 2); |
54 | - if($add['app'] && $add['id']) |
|
54 | + if ($add['app'] && $add['id']) |
|
55 | 55 | { |
56 | 56 | $context['list'][] = $add; |
57 | 57 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | unset($context['dropped_data']); |
61 | 61 | $need_reload = true; |
62 | 62 | } |
63 | - if($context['title']) |
|
63 | + if ($context['title']) |
|
64 | 64 | { |
65 | 65 | $this->title = $context['title']; |
66 | 66 | } |
67 | - foreach($context['list'] as &$item) |
|
67 | + foreach ($context['list'] as &$item) |
|
68 | 68 | { |
69 | - if($item['app'] == 'filemanager' || $item['app'] == 'file') |
|
69 | + if ($item['app'] == 'filemanager' || $item['app'] == 'file') |
|
70 | 70 | { |
71 | 71 | $item['app'] = 'file'; |
72 | 72 | $item['type'] = Vfs::mime_content_type($item['id']); |
@@ -105,21 +105,21 @@ discard block |
||
105 | 105 | * unique, if needed. |
106 | 106 | * @return string HTML fragment for display |
107 | 107 | */ |
108 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
108 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
109 | 109 | { |
110 | 110 | $etemplate->read('home.list'); |
111 | 111 | |
112 | 112 | $etemplate->set_dom_id($id); |
113 | 113 | $content = $this->context; |
114 | - if(!is_array($content['list'])) |
|
114 | + if (!is_array($content['list'])) |
|
115 | 115 | { |
116 | 116 | $content['list'] = Array(); |
117 | 117 | } |
118 | 118 | // Filemanager support - links need app = 'file' and type set |
119 | - foreach($content['list'] as &$list) |
|
119 | + foreach ($content['list'] as &$list) |
|
120 | 120 | { |
121 | - if($list['app'] == 'filemanager') $list['app'] = 'file'; |
|
122 | - if($list['app'] == 'file') |
|
121 | + if ($list['app'] == 'filemanager') $list['app'] = 'file'; |
|
122 | + if ($list['app'] == 'file') |
|
123 | 123 | { |
124 | 124 | $list['app'] = 'file'; |
125 | 125 | $list['path'] = $list['title'] = $list['icon'] = $list['id']; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - $etemplate->exec('home.home_list_portlet.exec',$content); |
|
130 | + $etemplate->exec('home.home_list_portlet.exec', $content); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'type' => 'drop', |
183 | 183 | 'caption' => lang('add'), |
184 | 184 | 'onExecute' => 'javaScript:app.home.add_link', |
185 | - 'acceptedTypes' => array('file','link') + array_keys($GLOBALS['egw_info']['apps']), |
|
185 | + 'acceptedTypes' => array('file', 'link') + array_keys($GLOBALS['egw_info']['apps']), |
|
186 | 186 | ) |
187 | 187 | ); |
188 | 188 | return $actions; |
@@ -202,6 +202,6 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function accept_drop() |
204 | 204 | { |
205 | - return array('file','link'); |
|
205 | + return array('file', 'link'); |
|
206 | 206 | } |
207 | 207 | } |
@@ -40,9 +40,15 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function __construct(Array &$context = array(), &$need_reload = false) |
42 | 42 | { |
43 | - if (false) parent::__construct(); |
|
43 | + if (false) |
|
44 | + { |
|
45 | + parent::__construct(); |
|
46 | + } |
|
44 | 47 | |
45 | - if(!is_array($context['list'])) $context['list'] = array(); |
|
48 | + if(!is_array($context['list'])) |
|
49 | + { |
|
50 | + $context['list'] = array(); |
|
51 | + } |
|
46 | 52 | |
47 | 53 | // Process dropped data (Should be GUIDs) into something useable |
48 | 54 | if($context['dropped_data']) |
@@ -118,7 +124,10 @@ discard block |
||
118 | 124 | // Filemanager support - links need app = 'file' and type set |
119 | 125 | foreach($content['list'] as &$list) |
120 | 126 | { |
121 | - if($list['app'] == 'filemanager') $list['app'] = 'file'; |
|
127 | + if($list['app'] == 'filemanager') |
|
128 | + { |
|
129 | + $list['app'] = 'file'; |
|
130 | + } |
|
122 | 131 | if($list['app'] == 'file') |
123 | 132 | { |
124 | 133 | $list['app'] = 'file'; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * Construct the portlet |
39 | 39 | * |
40 | 40 | */ |
41 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
41 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
42 | 42 | { |
43 | 43 | if (false) parent::__construct(); |
44 | 44 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $content = $this->context; |
114 | 114 | if(!is_array($content['list'])) |
115 | 115 | { |
116 | - $content['list'] = Array(); |
|
116 | + $content['list'] = array(); |
|
117 | 117 | } |
118 | 118 | // Filemanager support - links need app = 'file' and type set |
119 | 119 | foreach($content['list'] as &$list) |
@@ -113,7 +113,7 @@ |
||
113 | 113 | * If this portlet can be created by dropping, these are the drop types |
114 | 114 | * that are accepted |
115 | 115 | * |
116 | - * @return boolean|String[] |
|
116 | + * @return boolean |
|
117 | 117 | */ |
118 | 118 | public function accept_drop() |
119 | 119 | { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * unique, if needed. |
57 | 57 | * @param Etemplate $etemplate eTemplate to generate content |
58 | 58 | */ |
59 | - public abstract function exec($id = null, Etemplate &$etemplate = null); |
|
59 | + public abstract function exec($id = null, Etemplate&$etemplate = null); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Return a list of settings to customize the portlet. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | // Include the common attributes, or they won't get saved |
80 | 80 | $properties = array(); |
81 | - foreach(self::$common_attributes as $prop) |
|
81 | + foreach (self::$common_attributes as $prop) |
|
82 | 82 | { |
83 | 83 | $properties[$prop] = array('name' => $prop); |
84 | 84 | } |
@@ -123,6 +123,6 @@ discard block |
||
123 | 123 | |
124 | 124 | public function __toString() |
125 | 125 | { |
126 | - return get_called_class() . ' Context:' . array2string($this->context); |
|
126 | + return get_called_class().' Context:'.array2string($this->context); |
|
127 | 127 | } |
128 | 128 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param context Array portlet settings such as size, as well as values for properties |
35 | 35 | * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called) |
36 | 36 | */ |
37 | - public abstract function __construct(Array &$context = array(), &$need_reload = false); |
|
37 | + public abstract function __construct(array &$context = array(), &$need_reload = false); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Some descriptive information about the portlet, so that users can decide if |
@@ -155,7 +155,7 @@ |
||
155 | 155 | * Get a list of the user's portlets, and their associated values & settings, for display |
156 | 156 | * |
157 | 157 | * Actual portlet content is provided by each portlet. |
158 | - * @param template etemplate so attributes can be set |
|
158 | + * @param template Etemplate so attributes can be set |
|
159 | 159 | */ |
160 | 160 | protected function get_user_portlets(Etemplate &$template) |
161 | 161 | { |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | $content = array( |
50 | 50 | 'portlets' => $this->get_user_portlets($template) |
51 | 51 | ); |
52 | - $template->setElementAttribute('home.index','actions',$this->get_actions()); |
|
52 | + $template->setElementAttribute('home.index', 'actions', $this->get_actions()); |
|
53 | 53 | |
54 | 54 | $GLOBALS['egw_info']['flags']['app_header'] = lang('home'); |
55 | 55 | $GLOBALS['egw_info']['flags']['currentapp'] = 'home'; |
56 | 56 | |
57 | 57 | // Main screen message |
58 | 58 | Api\Translation::add_app('mainscreen'); |
59 | - $greeting = Api\Translation::translate('mainscreen_message',false,''); |
|
59 | + $greeting = Api\Translation::translate('mainscreen_message', false, ''); |
|
60 | 60 | |
61 | - if($greeting == 'mainscreen_message'|| empty($greeting)) |
|
61 | + if ($greeting == 'mainscreen_message' || empty($greeting)) |
|
62 | 62 | { |
63 | - Api\Translation::add_app('mainscreen','en'); // trying the en one |
|
64 | - $greeting = Api\Translation::translate('mainscreen_message',false,''); |
|
63 | + Api\Translation::add_app('mainscreen', 'en'); // trying the en one |
|
64 | + $greeting = Api\Translation::translate('mainscreen_message', false, ''); |
|
65 | 65 | } |
66 | - if(!($greeting == 'mainscreen_message'|| empty($greeting))) |
|
66 | + if (!($greeting == 'mainscreen_message' || empty($greeting))) |
|
67 | 67 | { |
68 | 68 | $content['mainscreen_message'] = $greeting; |
69 | 69 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | // Now run the portlets themselves |
74 | 74 | $attrs = array(); |
75 | - foreach($content['portlets'] as $portlet => $p_data) |
|
75 | + foreach ($content['portlets'] as $portlet => $p_data) |
|
76 | 76 | { |
77 | 77 | $id = $p_data['id']; |
78 | 78 | |
79 | - if(!$id) continue; |
|
79 | + if (!$id) continue; |
|
80 | 80 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
81 | 81 | } |
82 | 82 | |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | $add_portlets = $portlets; |
95 | 95 | $change_for_add = function(&$add_portlets) use (&$change_for_add) |
96 | 96 | { |
97 | - foreach($add_portlets as $id => &$add) |
|
97 | + foreach ($add_portlets as $id => &$add) |
|
98 | 98 | { |
99 | - if(is_array($add['children'])) |
|
99 | + if (is_array($add['children'])) |
|
100 | 100 | { |
101 | 101 | $change_for_add($add['children']); |
102 | 102 | } |
103 | - if($id && !$add['children']) |
|
103 | + if ($id && !$add['children']) |
|
104 | 104 | { |
105 | - $add['id'] = 'add_' . $id; |
|
105 | + $add['id'] = 'add_'.$id; |
|
106 | 106 | $add['class'] = 'add_'.$id; |
107 | 107 | } |
108 | 108 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | |
122 | 122 | // Add all known portlets as drop actions too. If there are multiple matches, there will be a menu |
123 | 123 | $drop_execute = 'javaScript:app.home.add_from_drop'; |
124 | - foreach($portlets as $app => &$children) |
|
124 | + foreach ($portlets as $app => &$children) |
|
125 | 125 | { |
126 | 126 | // Home portlets - uses link system, so all apps that support that are accepted |
127 | - if(!$children['children']) |
|
127 | + if (!$children['children']) |
|
128 | 128 | { |
129 | 129 | $children['class'] = $app; |
130 | 130 | $children['onExecute'] = $drop_execute; |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | else |
135 | 135 | { |
136 | - foreach($children['children'] as $portlet => $app_portlet) |
|
136 | + foreach ($children['children'] as $portlet => $app_portlet) |
|
137 | 137 | { |
138 | - if(!is_array($app_portlet)) continue; |
|
138 | + if (!is_array($app_portlet)) continue; |
|
139 | 139 | $app_portlet['class'] = $portlet; |
140 | - $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
|
140 | + $app_portlet['id'] = 'drop_'.$app_portlet['id']; |
|
141 | 141 | $app_portlet['onExecute'] = $drop_execute; |
142 | 142 | $app_portlet['acceptedTypes'] = $app; |
143 | 143 | $app_portlet['type'] = 'drop'; |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | * Actual portlet content is provided by each portlet. |
158 | 158 | * @param template etemplate so attributes can be set |
159 | 159 | */ |
160 | - protected function get_user_portlets(Etemplate &$template) |
|
160 | + protected function get_user_portlets(Etemplate&$template) |
|
161 | 161 | { |
162 | 162 | $portlets = array(); |
163 | 163 | |
164 | - foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
164 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
165 | 165 | { |
166 | - if(strpos($id,'portlet_') !== 0 || // Not a portlet |
|
166 | + if (strpos($id, 'portlet_') !== 0 || // Not a portlet |
|
167 | 167 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
168 | 168 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
169 | 169 | ) continue; |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | $classname = $context['class']; |
172 | 172 | |
173 | 173 | // Avoid portlets for apps user can't use (eg. from defaults/forced) |
174 | - list($app,$other) = explode('_',$classname); |
|
175 | - if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other; |
|
176 | - if(!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
174 | + list($app, $other) = explode('_', $classname); |
|
175 | + if (!$GLOBALS['egw_info']['apps'][$app]) $app .= '_'.$other; |
|
176 | + if (!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | // Get settings |
188 | 188 | // Exclude common attributes changed through UI and settings lacking a type |
189 | 189 | $settings = $portlet->get_properties(); |
190 | - foreach($settings as $key => $setting) |
|
190 | + foreach ($settings as $key => $setting) |
|
191 | 191 | { |
192 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
192 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
193 | 193 | } |
194 | 194 | $settings += $context; |
195 | - foreach(home_portlet::$common_attributes as $attr) |
|
195 | + foreach (home_portlet::$common_attributes as $attr) |
|
196 | 196 | { |
197 | 197 | unset($settings[$attr]); |
198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // Add in default for admins |
206 | 206 | self::create_default_actions($actions, $id); |
207 | 207 | |
208 | - $template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions); |
|
208 | + $template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions); |
|
209 | 209 | |
210 | 210 | $portlets[] = $portlet_content; |
211 | 211 | } |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
231 | 231 | { |
232 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
232 | + if (!$context['class']) $context['class'] = 'home_link_portlet'; |
|
233 | 233 | |
234 | 234 | // This should be set already, but just in case the execution path |
235 | 235 | // is different from normal... |
236 | - if(Api\Json\Response::isJSONResponse()) |
|
236 | + if (Api\Json\Response::isJSONResponse()) |
|
237 | 237 | { |
238 | 238 | $GLOBALS['egw']->framework->response = Api\Json\Response::get(); |
239 | 239 | } |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | |
249 | 249 | // Exclude common attributes changed through UI and settings lacking a type |
250 | 250 | $settings = $portlet->get_properties(); |
251 | - foreach($settings as $key => $setting) |
|
251 | + foreach ($settings as $key => $setting) |
|
252 | 252 | { |
253 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
253 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
254 | 254 | } |
255 | 255 | $settings += $context; |
256 | - foreach(home_portlet::$common_attributes as $attr) |
|
256 | + foreach (home_portlet::$common_attributes as $attr) |
|
257 | 257 | { |
258 | 258 | unset($settings[$attr]); |
259 | 259 | } |
@@ -268,31 +268,31 @@ discard block |
||
268 | 268 | self::create_default_actions($attributes['actions'], $id); |
269 | 269 | |
270 | 270 | // Set any provided common attributes (size, etc) |
271 | - foreach(home_portlet::$common_attributes as $name) |
|
271 | + foreach (home_portlet::$common_attributes as $name) |
|
272 | 272 | { |
273 | - if(array_key_exists($name, $context)) |
|
273 | + if (array_key_exists($name, $context)) |
|
274 | 274 | { |
275 | 275 | $attributes[$name] = $context[$name]; |
276 | 276 | } |
277 | 277 | } |
278 | - foreach($attributes as $attr => $value) |
|
278 | + foreach ($attributes as $attr => $value) |
|
279 | 279 | { |
280 | 280 | $etemplate->setElementAttribute($id, $attr, $value); |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Make sure custom javascript is loaded |
284 | 284 | $appname = $context['appname']; |
285 | - if(!$appname) |
|
285 | + if (!$appname) |
|
286 | 286 | { |
287 | - list($app) = explode('_',$classname); |
|
288 | - if($GLOBALS['egw_info']['apps'][$app]) |
|
287 | + list($app) = explode('_', $classname); |
|
288 | + if ($GLOBALS['egw_info']['apps'][$app]) |
|
289 | 289 | { |
290 | 290 | $appname = $app; |
291 | 291 | } |
292 | 292 | } |
293 | 293 | Framework::includeJS('', $classname, $appname ? $appname : 'home'); |
294 | 294 | |
295 | - if($full_exec) |
|
295 | + if ($full_exec) |
|
296 | 296 | { |
297 | 297 | $content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1); |
298 | 298 | } |
@@ -309,23 +309,23 @@ discard block |
||
309 | 309 | protected function get_legacy_portlets(&$content, &$attributes) |
310 | 310 | { |
311 | 311 | $sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']); |
312 | - $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display'); |
|
312 | + $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display'); |
|
313 | 313 | |
314 | - foreach($sorted_apps as $appname) |
|
314 | + foreach ($sorted_apps as $appname) |
|
315 | 315 | { |
316 | 316 | // If there's already [new] settings, or no preference, skip it |
317 | - if($content[$appname]) continue; |
|
317 | + if ($content[$appname]) continue; |
|
318 | 318 | $no_pref = true; |
319 | - foreach($portal_oldvarnames as $varcheck) |
|
319 | + foreach ($portal_oldvarnames as $varcheck) |
|
320 | 320 | { |
321 | 321 | $thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]; |
322 | - if($thisd) |
|
322 | + if ($thisd) |
|
323 | 323 | { |
324 | 324 | $no_pref = false; |
325 | 325 | break; |
326 | 326 | } |
327 | 327 | } |
328 | - if($no_pref || !Api\Hooks::exists('home', $appname)) |
|
328 | + if ($no_pref || !Api\Hooks::exists('home', $appname)) |
|
329 | 329 | { |
330 | 330 | continue; |
331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $_content = ''; |
337 | 337 | $_attributes = array(); |
338 | 338 | $this->get_portlet($appname, $context, $_content, $_attributes); |
339 | - if(trim($_content)) |
|
339 | + if (trim($_content)) |
|
340 | 340 | { |
341 | 341 | $content[$appname] = $_content; |
342 | 342 | $attributes[$appname] = $_attributes; |
@@ -355,24 +355,24 @@ discard block |
||
355 | 355 | |
356 | 356 | // Ignore some problem files and base classes that shouldn't be options |
357 | 357 | $ignore = array( |
358 | - '.','..', |
|
358 | + '.', '..', |
|
359 | 359 | 'class.home_portlet.inc.php', |
360 | 360 | 'class.home_legacy_portlet.inc.php', |
361 | 361 | 'class.home_favorite_portlet.inc.php' |
362 | 362 | ); |
363 | 363 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
364 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
364 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
365 | 365 | { |
366 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
367 | - $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
|
368 | - if(!$files) continue; |
|
366 | + if (in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
367 | + $files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/'); |
|
368 | + if (!$files) continue; |
|
369 | 369 | |
370 | - foreach($files as $entry) |
|
370 | + foreach ($files as $entry) |
|
371 | 371 | { |
372 | - if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet')) |
|
372 | + if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet')) |
|
373 | 373 | { |
374 | 374 | list(,$classname) = explode('.', $entry); |
375 | - if(class_exists($classname) && |
|
375 | + if (class_exists($classname) && |
|
376 | 376 | in_array('home_portlet', class_parents($classname, false))) |
377 | 377 | { |
378 | 378 | $classes[$appname][] = $classname; |
@@ -384,19 +384,19 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | - if(!$classes[$appname]) continue; |
|
387 | + if (!$classes[$appname]) continue; |
|
388 | 388 | |
389 | 389 | // Build 'Add' actions for each discovered portlet. |
390 | 390 | // Portlets from other apps go in sub-actions |
391 | - $add_to =& $list; |
|
392 | - if($classes[$appname] && $appname != 'home') |
|
391 | + $add_to = & $list; |
|
392 | + if ($classes[$appname] && $appname != 'home') |
|
393 | 393 | { |
394 | 394 | $list[$appname] = array( |
395 | 395 | 'caption' => lang($appname), |
396 | 396 | ); |
397 | - $add_to =& $list[$appname]['children']; |
|
397 | + $add_to = & $list[$appname]['children']; |
|
398 | 398 | } |
399 | - foreach($classes[$appname] as $portlet) |
|
399 | + foreach ($classes[$appname] as $portlet) |
|
400 | 400 | { |
401 | 401 | $instance = new $portlet(); |
402 | 402 | $desc = $instance->get_description(); |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | }, array(), 60); |
417 | 417 | |
418 | 418 | // Filter list by current user's permissions |
419 | - foreach(array_keys($list) as $appname) |
|
419 | + foreach (array_keys($list) as $appname) |
|
420 | 420 | { |
421 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
422 | - if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
421 | + if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
422 | + if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
423 | 423 | { |
424 | 424 | unset($list[$appname]); |
425 | 425 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | protected static function create_default_actions(&$actions, $portlet_id = null) |
438 | 438 | { |
439 | - if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
439 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
440 | 440 | { |
441 | 441 | $actions['add_default'] = array( |
442 | 442 | 'type' => 'popup', |
@@ -446,25 +446,25 @@ discard block |
||
446 | 446 | 'icon' => 'preference' |
447 | 447 | ); |
448 | 448 | // Customize for the given portlet |
449 | - if($portlet_id !== null) |
|
449 | + if ($portlet_id !== null) |
|
450 | 450 | { |
451 | - foreach(array('forced','group','default') as $location) |
|
451 | + foreach (array('forced', 'group', 'default') as $location) |
|
452 | 452 | { |
453 | 453 | $loc = $GLOBALS['egw']->preferences->$location; |
454 | 454 | |
455 | - if($loc['home'][$portlet_id]) |
|
455 | + if ($loc['home'][$portlet_id]) |
|
456 | 456 | { |
457 | 457 | // If it's forced, no point in setting default |
458 | - if($location == 'forced') |
|
458 | + if ($location == 'forced') |
|
459 | 459 | { |
460 | 460 | unset($actions['add_default']); |
461 | 461 | } |
462 | 462 | // If it's a group, we'd like to know which |
463 | - if($location == 'group') |
|
463 | + if ($location == 'group') |
|
464 | 464 | { |
465 | 465 | $options = array('account_type' => 'groups'); |
466 | - $groups = Api\Accounts::link_query('',$options); |
|
467 | - foreach(array_keys($groups) as $gid) |
|
466 | + $groups = Api\Accounts::link_query('', $options); |
|
467 | + foreach (array_keys($groups) as $gid) |
|
468 | 468 | { |
469 | 469 | $prefs = new Api\Preferences($gid); |
470 | 470 | $prefs->read_repository(); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | $actions['remove_default_'.$location] = array( |
479 | 479 | 'type' => 'popup', |
480 | - 'caption' => lang('Remove as default for %1',is_numeric($location) ? Api\Accounts::id2name($location,'account_fullname') : $location), |
|
480 | + 'caption' => lang('Remove as default for %1', is_numeric($location) ? Api\Accounts::id2name($location, 'account_fullname') : $location), |
|
481 | 481 | 'onExecute' => 'javaScript:app.home.set_default', |
482 | 482 | 'group' => 'Admins', |
483 | 483 | 'portlet_group' => $location |
@@ -488,14 +488,14 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | // Change action for forced |
491 | - if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
491 | + if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
492 | 492 | { |
493 | 493 | // No one can remove it |
494 | 494 | $actions['remove_portlet']['enabled'] = false; |
495 | - $actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')'; |
|
495 | + $actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')'; |
|
496 | 496 | |
497 | 497 | // Non-admins can't edit it |
498 | - if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
498 | + if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
499 | 499 | { |
500 | 500 | $actions['edit_settings']['enabled'] = false; |
501 | 501 | $actions['edit_settings']['visible'] = false; |
@@ -514,14 +514,14 @@ discard block |
||
514 | 514 | public function ajax_set_properties($portlet_id, $attributes, $values, $group = false) |
515 | 515 | { |
516 | 516 | //error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)"); |
517 | - if(!$attributes) |
|
517 | + if (!$attributes) |
|
518 | 518 | { |
519 | 519 | $attributes = array(); |
520 | 520 | } |
521 | 521 | |
522 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
522 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
523 | 523 | { |
524 | - if($group == 'forced') |
|
524 | + if ($group == 'forced') |
|
525 | 525 | { |
526 | 526 | // Quietly reject |
527 | 527 | return; |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | // Not an admin, can only override. |
530 | 530 | $group = false; |
531 | 531 | } |
532 | - if($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
532 | + if ($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
533 | 533 | { |
534 | 534 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
535 | 535 | } |
@@ -543,23 +543,23 @@ discard block |
||
543 | 543 | |
544 | 544 | $response = Api\Json\Response::get(); |
545 | 545 | |
546 | - if($values =='~reload~') |
|
546 | + if ($values == '~reload~') |
|
547 | 547 | { |
548 | 548 | $full_exec = true; |
549 | 549 | $values = array(); |
550 | 550 | } |
551 | - if($values == '~remove~') |
|
551 | + if ($values == '~remove~') |
|
552 | 552 | { |
553 | 553 | // Already removed client side, needs to be removed permanently |
554 | - $default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id]; |
|
554 | + $default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id]; |
|
555 | 555 | |
556 | - if($default) |
|
556 | + if ($default) |
|
557 | 557 | { |
558 | 558 | // Can't delete forced - not a UI option though |
559 | - if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
559 | + if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
560 | 560 | { |
561 | 561 | // Set a flag to override default instead of just delete |
562 | - $GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted'); |
|
562 | + $GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted'); |
|
563 | 563 | $GLOBALS['egw']->preferences->save_repository(); |
564 | 564 | } |
565 | 565 | } |
@@ -576,19 +576,19 @@ discard block |
||
576 | 576 | // Remove some constant stuff that winds up here |
577 | 577 | unset($values['edit_template']); |
578 | 578 | unset($values['readonly']); |
579 | - unset($values['disabled']);unset($values['no_lang']); |
|
579 | + unset($values['disabled']); unset($values['no_lang']); |
|
580 | 580 | unset($values['actions']); |
581 | 581 | unset($values['statustext']); |
582 | - unset($values['type']);unset($values['label']);unset($values['status']); |
|
583 | - unset($values['value']);unset($values['align']); |
|
582 | + unset($values['type']); unset($values['label']); unset($values['status']); |
|
583 | + unset($values['value']); unset($values['align']); |
|
584 | 584 | |
585 | 585 | // Get portlet settings, and merge new with old |
586 | 586 | $context = array_merge((array)$portlets[$portlet_id], $values); |
587 | 587 | $context['group'] = $group; |
588 | 588 | |
589 | 589 | // Handle add IDs |
590 | - $classname =& $context['class']; |
|
591 | - if(strpos($classname,'add_') == 0 && !class_exists($classname)) |
|
590 | + $classname = & $context['class']; |
|
591 | + if (strpos($classname, 'add_') == 0 && !class_exists($classname)) |
|
592 | 592 | { |
593 | 593 | $add = true; |
594 | 594 | $classname = substr($classname, 4); |
@@ -597,13 +597,13 @@ discard block |
||
597 | 597 | $portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec); |
598 | 598 | |
599 | 599 | $context['class'] = get_class($portlet); |
600 | - foreach($portlet->get_properties() as $property) |
|
600 | + foreach ($portlet->get_properties() as $property) |
|
601 | 601 | { |
602 | - if($values[$property['name']]) |
|
602 | + if ($values[$property['name']]) |
|
603 | 603 | { |
604 | 604 | $context[$property['name']] = $values[$property['name']]; |
605 | 605 | } |
606 | - elseif($portlets[$portlet_id][$property['name']]) |
|
606 | + elseif ($portlets[$portlet_id][$property['name']]) |
|
607 | 607 | { |
608 | 608 | $context[$property['name']] = $portlets[$portlet_id][$property['name']]; |
609 | 609 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $update = array('attributes' => $attributes); |
614 | 614 | |
615 | 615 | // New portlet? Flag going straight to edit mode |
616 | - if($add) |
|
616 | + if ($add) |
|
617 | 617 | { |
618 | 618 | $update['edit_settings'] = true; |
619 | 619 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } |
626 | 626 | |
627 | 627 | // Save updated preferences |
628 | - $prefs->save_repository(True,$type); |
|
628 | + $prefs->save_repository(True, $type); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -638,10 +638,10 @@ discard block |
||
638 | 638 | public static function ajax_set_default($action, $portlet_ids, $group) |
639 | 639 | { |
640 | 640 | // Admins only |
641 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
641 | + if (!$GLOBALS['egw_info']['apps']['admin']) return; |
|
642 | 642 | |
643 | 643 | // Load the appropriate group |
644 | - if($group) |
|
644 | + if ($group) |
|
645 | 645 | { |
646 | 646 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
647 | 647 | } |
@@ -653,30 +653,30 @@ discard block |
||
653 | 653 | |
654 | 654 | $type = is_numeric($group) ? "user" : $group; |
655 | 655 | |
656 | - if($action == 'add') |
|
656 | + if ($action == 'add') |
|
657 | 657 | { |
658 | - foreach($portlet_ids as $id) |
|
658 | + foreach ($portlet_ids as $id) |
|
659 | 659 | { |
660 | 660 | Api\Json\Response::get()->call('egw.message', lang("Set default")); |
661 | 661 | // Current user is setting the default, copy their settings |
662 | 662 | $settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id]; |
663 | 663 | $settings['group'] = $group; |
664 | - $prefs->add('home',$id,$settings,$type); |
|
664 | + $prefs->add('home', $id, $settings, $type); |
|
665 | 665 | |
666 | 666 | // Remove user's copy |
667 | - $GLOBALS['egw']->preferences->delete('home',$id); |
|
667 | + $GLOBALS['egw']->preferences->delete('home', $id); |
|
668 | 668 | $GLOBALS['egw']->preferences->save_repository(true); |
669 | 669 | } |
670 | 670 | } |
671 | 671 | else if ($action == "delete") |
672 | 672 | { |
673 | - foreach($portlet_ids as $id) |
|
673 | + foreach ($portlet_ids as $id) |
|
674 | 674 | { |
675 | 675 | Api\Json\Response::get()->call('egw.message', lang("Removed default")); |
676 | - $prefs->delete('home',$id, $type); |
|
676 | + $prefs->delete('home', $id, $type); |
|
677 | 677 | } |
678 | 678 | } |
679 | - $prefs->save_repository(false,$type); |
|
679 | + $prefs->save_repository(false, $type); |
|
680 | 680 | |
681 | 681 | // Update Api\Preferences client side for consistency |
682 | 682 | $prefs = $GLOBALS['egw']->preferences; |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | 'state' => array( |
730 | 730 | 'cat_id' => '0', |
731 | 731 | 'filter' => 'default', |
732 | - 'owner' => 0, // current user |
|
732 | + 'owner' => 0, // current user |
|
733 | 733 | 'sortby' => 'user', |
734 | 734 | 'planner_days' => '0', |
735 | 735 | 'view' => 'week', |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | { |
779 | 779 | unset($app_prefs['home']['portlet_setup142n']); |
780 | 780 | } |
781 | - foreach($app_prefs as $app => $prefs) |
|
781 | + foreach ($app_prefs as $app => $prefs) |
|
782 | 782 | { |
783 | - foreach($prefs as $name => $value) |
|
783 | + foreach ($prefs as $name => $value) |
|
784 | 784 | { |
785 | 785 | Api\Preferences::delete_preference($app, $name, 'default'); |
786 | 786 | $preferences->add($app, $name, $value, 'default'); |
@@ -801,10 +801,10 @@ discard block |
||
801 | 801 | */ |
802 | 802 | public static function setup_default_home() |
803 | 803 | { |
804 | - switch($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
804 | + switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
805 | 805 | { |
806 | 806 | case self::CURRENT_HOME_VERSION: |
807 | - return; // already up to date --> nothing to do |
|
807 | + return; // already up to date --> nothing to do |
|
808 | 808 | |
809 | 809 | default: |
810 | 810 | call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION))); |
@@ -76,7 +76,10 @@ discard block |
||
76 | 76 | { |
77 | 77 | $id = $p_data['id']; |
78 | 78 | |
79 | - if(!$id) continue; |
|
79 | + if(!$id) |
|
80 | + { |
|
81 | + continue; |
|
82 | + } |
|
80 | 83 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
81 | 84 | } |
82 | 85 | |
@@ -135,7 +138,10 @@ discard block |
||
135 | 138 | { |
136 | 139 | foreach($children['children'] as $portlet => $app_portlet) |
137 | 140 | { |
138 | - if(!is_array($app_portlet)) continue; |
|
141 | + if(!is_array($app_portlet)) |
|
142 | + { |
|
143 | + continue; |
|
144 | + } |
|
139 | 145 | $app_portlet['class'] = $portlet; |
140 | 146 | $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
141 | 147 | $app_portlet['onExecute'] = $drop_execute; |
@@ -166,14 +172,21 @@ discard block |
||
166 | 172 | if(strpos($id,'portlet_') !== 0 || // Not a portlet |
167 | 173 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
168 | 174 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
169 | - ) continue; |
|
175 | + ) |
|
176 | + { |
|
177 | + continue; |
|
178 | + } |
|
170 | 179 | |
171 | 180 | $classname = $context['class']; |
172 | 181 | |
173 | 182 | // Avoid portlets for apps user can't use (eg. from defaults/forced) |
174 | 183 | list($app,$other) = explode('_',$classname); |
175 | - if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other; |
|
176 | - if(!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
184 | + if(!$GLOBALS['egw_info']['apps'][$app]) |
|
185 | + { |
|
186 | + $app .='_'.$other; |
|
187 | + } |
|
188 | + if(!$GLOBALS['egw_info']['user']['apps'][$app]) |
|
189 | + { |
|
177 | 190 | continue; |
178 | 191 | } |
179 | 192 | |
@@ -189,7 +202,10 @@ discard block |
||
189 | 202 | $settings = $portlet->get_properties(); |
190 | 203 | foreach($settings as $key => $setting) |
191 | 204 | { |
192 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
205 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
206 | + { |
|
207 | + unset($settings[$key]); |
|
208 | + } |
|
193 | 209 | } |
194 | 210 | $settings += $context; |
195 | 211 | foreach(home_portlet::$common_attributes as $attr) |
@@ -229,7 +245,10 @@ discard block |
||
229 | 245 | */ |
230 | 246 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
231 | 247 | { |
232 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
248 | + if(!$context['class']) |
|
249 | + { |
|
250 | + $context['class'] = 'home_link_portlet'; |
|
251 | + } |
|
233 | 252 | |
234 | 253 | // This should be set already, but just in case the execution path |
235 | 254 | // is different from normal... |
@@ -250,7 +269,10 @@ discard block |
||
250 | 269 | $settings = $portlet->get_properties(); |
251 | 270 | foreach($settings as $key => $setting) |
252 | 271 | { |
253 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
272 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
273 | + { |
|
274 | + unset($settings[$key]); |
|
275 | + } |
|
254 | 276 | } |
255 | 277 | $settings += $context; |
256 | 278 | foreach(home_portlet::$common_attributes as $attr) |
@@ -314,7 +336,10 @@ discard block |
||
314 | 336 | foreach($sorted_apps as $appname) |
315 | 337 | { |
316 | 338 | // If there's already [new] settings, or no preference, skip it |
317 | - if($content[$appname]) continue; |
|
339 | + if($content[$appname]) |
|
340 | + { |
|
341 | + continue; |
|
342 | + } |
|
318 | 343 | $no_pref = true; |
319 | 344 | foreach($portal_oldvarnames as $varcheck) |
320 | 345 | { |
@@ -349,7 +374,8 @@ discard block |
||
349 | 374 | */ |
350 | 375 | protected function get_portlet_list() |
351 | 376 | { |
352 | - $list = Api\Cache::getTree('home', 'portlet_classes', function() { |
|
377 | + $list = Api\Cache::getTree('home', 'portlet_classes', function() |
|
378 | + { |
|
353 | 379 | $list = array(); |
354 | 380 | $classes = array(); |
355 | 381 | |
@@ -363,9 +389,15 @@ discard block |
||
363 | 389 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
364 | 390 | foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
365 | 391 | { |
366 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
392 | + if(in_array($appname, array('phpgwapi', 'felamimail'))) |
|
393 | + { |
|
394 | + continue; |
|
395 | + } |
|
367 | 396 | $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
368 | - if(!$files) continue; |
|
397 | + if(!$files) |
|
398 | + { |
|
399 | + continue; |
|
400 | + } |
|
369 | 401 | |
370 | 402 | foreach($files as $entry) |
371 | 403 | { |
@@ -384,7 +416,10 @@ discard block |
||
384 | 416 | } |
385 | 417 | } |
386 | 418 | |
387 | - if(!$classes[$appname]) continue; |
|
419 | + if(!$classes[$appname]) |
|
420 | + { |
|
421 | + continue; |
|
422 | + } |
|
388 | 423 | |
389 | 424 | // Build 'Add' actions for each discovered portlet. |
390 | 425 | // Portlets from other apps go in sub-actions |
@@ -418,7 +453,8 @@ discard block |
||
418 | 453 | // Filter list by current user's permissions |
419 | 454 | foreach(array_keys($list) as $appname) |
420 | 455 | { |
421 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
456 | + if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) |
|
457 | + { |
|
422 | 458 | if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
423 | 459 | { |
424 | 460 | unset($list[$appname]); |
@@ -638,7 +674,10 @@ discard block |
||
638 | 674 | public static function ajax_set_default($action, $portlet_ids, $group) |
639 | 675 | { |
640 | 676 | // Admins only |
641 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
677 | + if(!$GLOBALS['egw_info']['apps']['admin']) |
|
678 | + { |
|
679 | + return; |
|
680 | + } |
|
642 | 681 | |
643 | 682 | // Load the appropriate group |
644 | 683 | if($group) |
@@ -701,7 +740,10 @@ discard block |
||
701 | 740 | $preferences = $GLOBALS['egw']->preferences; |
702 | 741 | $preferences->read_repository(); |
703 | 742 | $lang = $preferences->default['common']['lang']; |
704 | - if (empty($lang)) $lang = 'en'; |
|
743 | + if (empty($lang)) |
|
744 | + { |
|
745 | + $lang = 'en'; |
|
746 | + } |
|
705 | 747 | |
706 | 748 | Api\Translation::add_app('calendar', $lang); |
707 | 749 | $weekview = lang('Weekview'); |
@@ -118,8 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * imports entries according to given definition object. |
120 | 120 | * @param resource $_stream |
121 | - * @param string $_charset |
|
122 | - * @param definition $_definition |
|
121 | + * @param importexport_definition $_definition |
|
123 | 122 | */ |
124 | 123 | public function import( $_stream, importexport_definition $_definition ) { |
125 | 124 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -222,7 +221,7 @@ discard block |
||
222 | 221 | * |
223 | 222 | * Updates the count of actions taken |
224 | 223 | * |
225 | - * @return boolean success |
|
224 | + * @return null|boolean success |
|
226 | 225 | */ |
227 | 226 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
228 | 227 | { |
@@ -274,7 +273,7 @@ discard block |
||
274 | 273 | * @param condition array = array('string' => field name) |
275 | 274 | * @param matches - On return, will be filled with matching records |
276 | 275 | * |
277 | - * @return boolean |
|
276 | + * @return boolean|null |
|
278 | 277 | */ |
279 | 278 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
280 | 279 | { |
@@ -451,7 +450,7 @@ discard block |
||
451 | 450 | /** |
452 | 451 | * Allows an extending class to alter a row for preview |
453 | 452 | * |
454 | - * @param egw_record $row_entry |
|
453 | + * @param importexport_iface_egw_record $row_entry |
|
455 | 454 | */ |
456 | 455 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
457 | 456 | { |
@@ -523,7 +522,7 @@ discard block |
||
523 | 522 | * Get the primary key for an entry based on a custom field |
524 | 523 | * Returns key, so regular linking can take over |
525 | 524 | * |
526 | - * @param int $record_number Row number, used for errors |
|
525 | + * @param int $record_num Row number, used for errors |
|
527 | 526 | * @param string $app Target application name |
528 | 527 | * @param string $value CSV value in the form of custom_field_name:value |
529 | 528 | */ |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $record_class = isset(static::$record_class) ? static::$record_class : "{$app}_egw_record"; |
164 | 164 | |
165 | 165 | // Needed for categories to work right |
166 | - $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
|
166 | + $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
|
167 | 167 | |
168 | 168 | $this->init($_definition); |
169 | 169 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - *Import a single record |
|
219 | - * |
|
220 | - * You don't need to worry about mappings or translations, they've been done already. |
|
221 | - * You do need to handle the conditions and the actions taken. |
|
222 | - * |
|
223 | - * Updates the count of actions taken |
|
224 | - * |
|
225 | - * @return boolean success |
|
226 | - */ |
|
218 | + *Import a single record |
|
219 | + * |
|
220 | + * You don't need to worry about mappings or translations, they've been done already. |
|
221 | + * You do need to handle the conditions and the actions taken. |
|
222 | + * |
|
223 | + * Updates the count of actions taken |
|
224 | + * |
|
225 | + * @return boolean success |
|
226 | + */ |
|
227 | 227 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
228 | 228 | { |
229 | 229 | if ( $this->definition->plugin_options['conditions'] ) { |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @param stream $stream |
404 | 404 | * @param importexport_definition $definition |
405 | 405 | * @return String HTML for preview |
406 | - */ |
|
406 | + */ |
|
407 | 407 | public function preview( $stream, importexport_definition $definition ) |
408 | 408 | { |
409 | 409 | $this->import($stream, $definition); |
@@ -639,37 +639,37 @@ discard block |
||
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
642 | - * Returns warnings that were encountered during importing |
|
643 | - * Maximum of one warning message per record, but you can append if you need to |
|
644 | - * |
|
645 | - * @return Array ( |
|
646 | - * record_# => warning message |
|
647 | - * ) |
|
648 | - */ |
|
642 | + * Returns warnings that were encountered during importing |
|
643 | + * Maximum of one warning message per record, but you can append if you need to |
|
644 | + * |
|
645 | + * @return Array ( |
|
646 | + * record_# => warning message |
|
647 | + * ) |
|
648 | + */ |
|
649 | 649 | public function get_warnings() { |
650 | 650 | return $this->warnings; |
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
654 | - * Returns errors that were encountered during importing |
|
655 | - * Maximum of one error message per record, but you can append if you need to |
|
656 | - * |
|
657 | - * @return Array ( |
|
658 | - * record_# => error message |
|
659 | - * ) |
|
660 | - */ |
|
654 | + * Returns errors that were encountered during importing |
|
655 | + * Maximum of one error message per record, but you can append if you need to |
|
656 | + * |
|
657 | + * @return Array ( |
|
658 | + * record_# => error message |
|
659 | + * ) |
|
660 | + */ |
|
661 | 661 | public function get_errors() { |
662 | 662 | return $this->errors; |
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
666 | - * Returns a list of actions taken, and the number of records for that action. |
|
667 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
668 | - * |
|
669 | - * @return Array ( |
|
670 | - * action => record count |
|
671 | - * ) |
|
672 | - */ |
|
666 | + * Returns a list of actions taken, and the number of records for that action. |
|
667 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
668 | + * |
|
669 | + * @return Array ( |
|
670 | + * action => record count |
|
671 | + * ) |
|
672 | + */ |
|
673 | 673 | public function get_results() { |
674 | 674 | return $this->results; |
675 | 675 | } |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | * should get you started on building a CSV plugin for an application fairly quickly. |
19 | 19 | * |
20 | 20 | */ |
21 | -abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
21 | +abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
22 | 22 | |
23 | 23 | protected static $plugin_options = array( |
24 | - 'fieldsep', // char |
|
25 | - 'charset', // string |
|
26 | - 'record_owner', // int |
|
27 | - 'update_cats', // string {override|add} overides record |
|
24 | + 'fieldsep', // char |
|
25 | + 'charset', // string |
|
26 | + 'record_owner', // int |
|
27 | + 'update_cats', // string {override|add} overides record |
|
28 | 28 | // with cat(s) from csv OR add the cat from |
29 | 29 | // csv file to exeisting cat(s) of record |
30 | 30 | 'num_header_lines', // int number of header lines |
31 | 31 | 'field_conversion', // array( $csv_col_num => conversion) |
32 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
33 | - 'conditions', /* => array containing condition arrays: |
|
32 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
33 | + 'conditions', /* => array containing condition arrays: |
|
34 | 34 | 'type' => exists, // exists |
35 | 35 | 'string' => '#kundennummer', |
36 | 36 | 'true' => array( |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * Actions wich could be done to data entries |
49 | 49 | * If your plugin supports different actions, be sure to modify this array |
50 | 50 | */ |
51 | - protected static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
51 | + protected static $actions = array('none', 'update', 'insert', 'delete',); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Conditions for actions |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @var array |
58 | 58 | */ |
59 | - protected static $conditions = array( 'exists', 'equal', 'less_than'); |
|
59 | + protected static $conditions = array('exists', 'equal', 'less_than'); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * This is the definition that will be used to deal with the CSV file |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $_charset |
122 | 122 | * @param definition $_definition |
123 | 123 | */ |
124 | - public function import( $_stream, importexport_definition $_definition ) { |
|
125 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
124 | + public function import($_stream, importexport_definition $_definition) { |
|
125 | + $import_csv = new importexport_import_csv($_stream, array( |
|
126 | 126 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
127 | 127 | 'charset' => $_definition->plugin_options['charset'], |
128 | 128 | )); |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | $this->definition = $_definition; |
131 | 131 | |
132 | 132 | // user, is admin ? |
133 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
133 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
134 | 134 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
135 | 135 | |
136 | 136 | // dry run? |
137 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
137 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
138 | 138 | |
139 | 139 | // set FieldMapping. |
140 | 140 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
144 | 144 | |
145 | 145 | //check if file has a header lines |
146 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
146 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
147 | 147 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
148 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
148 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
149 | 149 | // First method is preferred |
150 | 150 | $import_csv->skip_records(1); |
151 | 151 | } |
@@ -167,38 +167,38 @@ discard block |
||
167 | 167 | |
168 | 168 | $this->init($_definition); |
169 | 169 | |
170 | - while ( $record = $import_csv->get_record() ) { |
|
170 | + while ($record = $import_csv->get_record()) { |
|
171 | 171 | $success = false; |
172 | 172 | |
173 | 173 | // don't import empty records |
174 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
174 | + if (count(array_unique($record)) < 2) continue; |
|
175 | 175 | |
176 | 176 | |
177 | 177 | $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); |
178 | - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
178 | + if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
179 | 179 | |
180 | 180 | $egw_record = new $record_class(); |
181 | 181 | $egw_record->set_record($record); |
182 | 182 | $success = $this->import_record($egw_record, $import_csv); |
183 | 183 | |
184 | - if($success) |
|
184 | + if ($success) |
|
185 | 185 | { |
186 | 186 | $this->do_special_fields($egw_record, $import_csv); |
187 | 187 | } |
188 | - if($success) $count++; |
|
188 | + if ($success) $count++; |
|
189 | 189 | |
190 | 190 | // Add some more time |
191 | - if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
|
191 | + if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
|
192 | 192 | { |
193 | 193 | set_time_limit(10); |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Keep a few records for preview, but process the whole file |
197 | - if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
197 | + if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
198 | 198 | { |
199 | 199 | $this->preview_records[] = $egw_record; |
200 | 200 | } |
201 | - if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) |
|
201 | + if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) |
|
202 | 202 | { |
203 | 203 | $this->errors[] = 'Too many errors, aborted'; |
204 | 204 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * Stub to hook into import initialization - set lookups, etc. |
212 | 212 | */ |
213 | - protected function init(importexport_definition &$definition) |
|
213 | + protected function init(importexport_definition&$definition) |
|
214 | 214 | { |
215 | 215 | } |
216 | 216 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return boolean success |
226 | 226 | */ |
227 | - protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
|
227 | + protected function import_record(importexport_iface_egw_record&$record, &$import_csv) |
|
228 | 228 | { |
229 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
230 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
229 | + if ($this->definition->plugin_options['conditions']) { |
|
230 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
231 | 231 | $result = false; |
232 | - switch ( $condition['type'] ) { |
|
232 | + switch ($condition['type']) { |
|
233 | 233 | // exists |
234 | 234 | case 'exists' : |
235 | 235 | // Check for that record |
@@ -245,23 +245,23 @@ discard block |
||
245 | 245 | die('condition / action not supported!!!'); |
246 | 246 | break; |
247 | 247 | } |
248 | - if($result) |
|
248 | + if ($result) |
|
249 | 249 | { |
250 | 250 | // Apply true action to any matching records found |
251 | 251 | $action = $condition['true']; |
252 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
252 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
253 | 253 | } |
254 | 254 | else |
255 | 255 | { |
256 | 256 | // Apply false action if no matching records found |
257 | 257 | $action = $condition['false']; |
258 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
258 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
259 | 259 | } |
260 | 260 | if ($action['stop']) break; |
261 | 261 | } |
262 | 262 | } else { |
263 | 263 | // unconditional insert |
264 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
264 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $success; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
|
279 | + protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$matches = array()) |
|
280 | 280 | { |
281 | 281 | } |
282 | 282 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | - protected function equal(importexport_iface_egw_record &$record, Array &$condition) |
|
291 | + protected function equal(importexport_iface_egw_record&$record, Array &$condition) |
|
292 | 292 | { |
293 | 293 | $field = $condition['string']; |
294 | 294 | return $record->$field == $condition['op_2']; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return boolean |
305 | 305 | */ |
306 | - protected function less_than(importexport_iface_egw_record &$record, Array &$condition) |
|
306 | + protected function less_than(importexport_iface_egw_record&$record, Array &$condition) |
|
307 | 307 | { |
308 | 308 | $field = $condition['string']; |
309 | 309 | return $record->$field < $condition['op_2']; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @param int $record_num Which record number is being dealt with. Used for error messages. |
323 | 323 | * @return bool success or not |
324 | 324 | */ |
325 | - protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ); |
|
325 | + protected abstract function action($_action, importexport_iface_egw_record&$record, $record_num = 0); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Handle special fields |
@@ -332,51 +332,51 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param importexport_iface_egw_record $record |
334 | 334 | */ |
335 | - protected function do_special_fields(importexport_iface_egw_record &$record, &$import_csv) |
|
335 | + protected function do_special_fields(importexport_iface_egw_record&$record, &$import_csv) |
|
336 | 336 | { |
337 | 337 | $id = $record->get_identifier(); |
338 | 338 | |
339 | 339 | // Warn if there's no ID unless it's a dry_run because there probably won't be an ID then |
340 | - if(!$this->dry_run && !$id) |
|
340 | + if (!$this->dry_run && !$id) |
|
341 | 341 | { |
342 | 342 | $this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record"; |
343 | 343 | return; |
344 | 344 | } |
345 | 345 | |
346 | - foreach(self::$special_fields as $field => $desc) { |
|
347 | - if(!$record->$field) continue; |
|
348 | - if(strpos($field, 'link') === 0) { |
|
349 | - list($app, $app_id) = explode(':', $record->$field,2); |
|
346 | + foreach (self::$special_fields as $field => $desc) { |
|
347 | + if (!$record->$field) continue; |
|
348 | + if (strpos($field, 'link') === 0) { |
|
349 | + list($app, $app_id) = explode(':', $record->$field, 2); |
|
350 | 350 | |
351 | - list($link, $type) = explode('_',$field); |
|
351 | + list($link, $type) = explode('_', $field); |
|
352 | 352 | |
353 | 353 | // Searching, take first result |
354 | - if($type == 'custom') |
|
354 | + if ($type == 'custom') |
|
355 | 355 | { |
356 | 356 | $app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position()); |
357 | 357 | } |
358 | - else if($type == 'search') |
|
358 | + else if ($type == 'search') |
|
359 | 359 | { |
360 | 360 | $result = Link::query($app, $app_id); |
361 | 361 | do |
362 | 362 | { |
363 | 363 | $app_id = key($result); |
364 | 364 | shift($result); |
365 | - } while($result && !$app_id); |
|
365 | + } while ($result && !$app_id); |
|
366 | 366 | } |
367 | 367 | } else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) { |
368 | 368 | $app = $field; |
369 | 369 | $app_id = $record->$field; |
370 | 370 | |
371 | 371 | // Searching, take first result |
372 | - if(!is_numeric($app_id)) |
|
372 | + if (!is_numeric($app_id)) |
|
373 | 373 | { |
374 | 374 | $result = Link::query($app, $app_id); |
375 | 375 | do |
376 | 376 | { |
377 | 377 | $app_id = key($result); |
378 | 378 | shift($result); |
379 | - } while($result && !$app_id); |
|
379 | + } while ($result && !$app_id); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | else if ($field == 'contact') |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id)) |
389 | 389 | { |
390 | - $link_id = Link::link($this->definition->application,$id,$app,$app_id); |
|
390 | + $link_id = Link::link($this->definition->application, $id, $app, $app_id); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | * @param importexport_definition $definition |
405 | 405 | * @return String HTML for preview |
406 | 406 | */ |
407 | - public function preview( $stream, importexport_definition $definition ) |
|
407 | + public function preview($stream, importexport_definition $definition) |
|
408 | 408 | { |
409 | 409 | $this->import($stream, $definition); |
410 | 410 | rewind($stream); |
411 | 411 | |
412 | 412 | // Set up result |
413 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
413 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
414 | 414 | |
415 | 415 | // Load labels for app |
416 | 416 | $record_class = get_class($this->preview_records[0]); |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | $labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']); |
420 | 420 | |
421 | 421 | $plugin = get_called_class(); |
422 | - $wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin); |
|
422 | + $wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin); |
|
423 | 423 | try { |
424 | 424 | $wizard = new $wizard_name; |
425 | 425 | $fields = $wizard->get_import_fields(); |
426 | - foreach($labels as $field => &$label) |
|
426 | + foreach ($labels as $field => &$label) |
|
427 | 427 | { |
428 | - if($fields[$field]) $label = $fields[$field]; |
|
428 | + if ($fields[$field]) $label = $fields[$field]; |
|
429 | 429 | } |
430 | 430 | } catch (Exception $e) { |
431 | 431 | Api\Translation::add_app($definition->application); |
432 | - foreach($labels as $field => &$label) { |
|
432 | + foreach ($labels as $field => &$label) { |
|
433 | 433 | $label = lang($label); |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | 437 | // Set up HTML |
438 | 438 | $rows['h1'] = $labels; |
439 | - foreach($this->preview_records as $i => $row_data) |
|
439 | + foreach ($this->preview_records as $i => $row_data) |
|
440 | 440 | { |
441 | 441 | // Convert to human-friendly |
442 | - importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups); |
|
442 | + importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups); |
|
443 | 443 | $this->row_preview($row_data); |
444 | 444 | $rows[] = $row_data->get_record_array(); |
445 | 445 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param egw_record $row_entry |
455 | 455 | */ |
456 | - protected function row_preview(importexport_iface_egw_record &$row_entry) |
|
456 | + protected function row_preview(importexport_iface_egw_record&$row_entry) |
|
457 | 457 | { |
458 | 458 | } |
459 | 459 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @param string $org_name |
469 | 469 | * @return int|boolean Contact ID of first match, or false if none found |
470 | 470 | */ |
471 | - public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) { |
|
471 | + public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) { |
|
472 | 472 | |
473 | 473 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
474 | 474 | static $contacts; |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
479 | 479 | } |
480 | 480 | $n_family = trim($n_family); |
481 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
481 | + if (!is_null($n_given)) $n_given = trim($n_given); |
|
482 | 482 | if (!is_object($contacts)) |
483 | 483 | { |
484 | 484 | $contacts = new Api\Contacts(); |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | if (!is_null($org_name)) // org_name given? |
487 | 487 | { |
488 | 488 | $org_name = trim($org_name); |
489 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
|
489 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name"); |
|
490 | 490 | if (!count($addrs)) |
491 | 491 | { |
492 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
|
492 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name'); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
@@ -498,11 +498,11 @@ discard block |
||
498 | 498 | } |
499 | 499 | if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
500 | 500 | { |
501 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
|
501 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn'); |
|
502 | 502 | } |
503 | 503 | if (count($addrs)) |
504 | 504 | { |
505 | - if(!$record || !$record->get_identifier()) |
|
505 | + if (!$record || !$record->get_identifier()) |
|
506 | 506 | { |
507 | 507 | return $addrs[0]['id']; |
508 | 508 | } |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | { |
513 | 513 | $id = key($addrs); |
514 | 514 | array_shift($addrs); |
515 | - } while($addrs && !$id && $id == $record->get_identifier()); |
|
515 | + } while ($addrs && !$id && $id == $record->get_identifier()); |
|
516 | 516 | return $id; |
517 | 517 | } |
518 | 518 | } |
@@ -527,22 +527,22 @@ discard block |
||
527 | 527 | * @param string $app Target application name |
528 | 528 | * @param string $value CSV value in the form of custom_field_name:value |
529 | 529 | */ |
530 | - protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num) |
|
530 | + protected function link_by_cf(importexport_iface_egw_record&$record, $app, $value, $record_num) |
|
531 | 531 | { |
532 | 532 | $app_id = false; |
533 | 533 | |
534 | - list($custom_field, $value) = explode(':',$value); |
|
534 | + list($custom_field, $value) = explode(':', $value); |
|
535 | 535 | // Find matching entry |
536 | - if($app && $custom_field && $value) |
|
536 | + if ($app && $custom_field && $value) |
|
537 | 537 | { |
538 | 538 | $cfs = Api\Storage\Customfields::get($app); |
539 | 539 | // Error if no custom fields, probably something wrong in definition |
540 | - if(!$cfs[$custom_field]) |
|
540 | + if (!$cfs[$custom_field]) |
|
541 | 541 | { |
542 | 542 | // Check for users specifing label instead of name |
543 | - foreach($cfs as $name => $settings) |
|
543 | + foreach ($cfs as $name => $settings) |
|
544 | 544 | { |
545 | - if(strtolower($settings['label']) == strtolower($custom_field)) |
|
545 | + if (strtolower($settings['label']) == strtolower($custom_field)) |
|
546 | 546 | { |
547 | 547 | $custom_field = $name; |
548 | 548 | break; |
@@ -551,30 +551,30 @@ discard block |
||
551 | 551 | } |
552 | 552 | |
553 | 553 | // Couldn't find field, give an error - something's wrong |
554 | - if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) { |
|
554 | + if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) { |
|
555 | 555 | $this->errors[$record_num] .= lang('No custom field "%1" for %2.', |
556 | 556 | $custom_field, lang($app)); |
557 | 557 | return false; |
558 | 558 | } |
559 | - if($custom_field[0] != '#') $custom_field = '#' . $custom_field; |
|
559 | + if ($custom_field[0] != '#') $custom_field = '#'.$custom_field; |
|
560 | 560 | error_log("Searching for $custom_field = $value"); |
561 | 561 | // Search |
562 | - if(Link::get_registry($app, 'query')) |
|
562 | + if (Link::get_registry($app, 'query')) |
|
563 | 563 | { |
564 | - $options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value))); |
|
564 | + $options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value))); |
|
565 | 565 | $result = Link::query($app, '', $options); |
566 | 566 | |
567 | 567 | // Only one allowed |
568 | - if($record->get_identifier()) |
|
568 | + if ($record->get_identifier()) |
|
569 | 569 | { |
570 | - while(key($result) == $record->get_identifier()) |
|
570 | + while (key($result) == $record->get_identifier()) |
|
571 | 571 | { |
572 | 572 | array_shift($result); |
573 | 573 | } |
574 | 574 | } |
575 | - if(count($result) != 1) |
|
575 | + if (count($result) != 1) |
|
576 | 576 | { |
577 | - $this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') . |
|
577 | + $this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : ''). |
|
578 | 578 | lang('Unable to link to %3 by custom field "%1": "%4". %2 matches.', |
579 | 579 | $custom_field, count($result), lang($app), $options['filter'][0] |
580 | 580 | ); |
@@ -18,7 +18,8 @@ discard block |
||
18 | 18 | * should get you started on building a CSV plugin for an application fairly quickly. |
19 | 19 | * |
20 | 20 | */ |
21 | -abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
21 | +abstract class importexport_basic_import_csv implements importexport_iface_import_plugin |
|
22 | +{ |
|
22 | 23 | |
23 | 24 | protected static $plugin_options = array( |
24 | 25 | 'fieldsep', // char |
@@ -121,7 +122,8 @@ discard block |
||
121 | 122 | * @param string $_charset |
122 | 123 | * @param definition $_definition |
123 | 124 | */ |
124 | - public function import( $_stream, importexport_definition $_definition ) { |
|
125 | + public function import( $_stream, importexport_definition $_definition ) |
|
126 | + { |
|
125 | 127 | $import_csv = new importexport_import_csv( $_stream, array( |
126 | 128 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
127 | 129 | 'charset' => $_definition->plugin_options['charset'], |
@@ -143,9 +145,12 @@ discard block |
||
143 | 145 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
144 | 146 | |
145 | 147 | //check if file has a header lines |
146 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
148 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
149 | + { |
|
147 | 150 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
148 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
151 | + } |
|
152 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
153 | + { |
|
149 | 154 | // First method is preferred |
150 | 155 | $import_csv->skip_records(1); |
151 | 156 | } |
@@ -167,15 +172,22 @@ discard block |
||
167 | 172 | |
168 | 173 | $this->init($_definition); |
169 | 174 | |
170 | - while ( $record = $import_csv->get_record() ) { |
|
175 | + while ( $record = $import_csv->get_record() ) |
|
176 | + { |
|
171 | 177 | $success = false; |
172 | 178 | |
173 | 179 | // don't import empty records |
174 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
180 | + if( count( array_unique( $record ) ) < 2 ) |
|
181 | + { |
|
182 | + continue; |
|
183 | + } |
|
175 | 184 | |
176 | 185 | |
177 | 186 | $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); |
178 | - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
187 | + if($warning) |
|
188 | + { |
|
189 | + $this->warnings[$import_csv->get_current_position()] = $warning; |
|
190 | + } |
|
179 | 191 | |
180 | 192 | $egw_record = new $record_class(); |
181 | 193 | $egw_record->set_record($record); |
@@ -185,7 +197,10 @@ discard block |
||
185 | 197 | { |
186 | 198 | $this->do_special_fields($egw_record, $import_csv); |
187 | 199 | } |
188 | - if($success) $count++; |
|
200 | + if($success) |
|
201 | + { |
|
202 | + $count++; |
|
203 | + } |
|
189 | 204 | |
190 | 205 | // Add some more time |
191 | 206 | if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
@@ -226,10 +241,13 @@ discard block |
||
226 | 241 | */ |
227 | 242 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
228 | 243 | { |
229 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
230 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
244 | + if ( $this->definition->plugin_options['conditions'] ) |
|
245 | + { |
|
246 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
247 | + { |
|
231 | 248 | $result = false; |
232 | - switch ( $condition['type'] ) { |
|
249 | + switch ( $condition['type'] ) |
|
250 | + { |
|
233 | 251 | // exists |
234 | 252 | case 'exists' : |
235 | 253 | // Check for that record |
@@ -257,9 +275,14 @@ discard block |
||
257 | 275 | $action = $condition['false']; |
258 | 276 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
259 | 277 | } |
260 | - if ($action['stop']) break; |
|
278 | + if ($action['stop']) |
|
279 | + { |
|
280 | + break; |
|
281 | + } |
|
261 | 282 | } |
262 | - } else { |
|
283 | + } |
|
284 | + else |
|
285 | + { |
|
263 | 286 | // unconditional insert |
264 | 287 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
265 | 288 | } |
@@ -343,9 +366,14 @@ discard block |
||
343 | 366 | return; |
344 | 367 | } |
345 | 368 | |
346 | - foreach(self::$special_fields as $field => $desc) { |
|
347 | - if(!$record->$field) continue; |
|
348 | - if(strpos($field, 'link') === 0) { |
|
369 | + foreach(self::$special_fields as $field => $desc) |
|
370 | + { |
|
371 | + if(!$record->$field) |
|
372 | + { |
|
373 | + continue; |
|
374 | + } |
|
375 | + if(strpos($field, 'link') === 0) |
|
376 | + { |
|
349 | 377 | list($app, $app_id) = explode(':', $record->$field,2); |
350 | 378 | |
351 | 379 | list($link, $type) = explode('_',$field); |
@@ -364,7 +392,9 @@ discard block |
||
364 | 392 | shift($result); |
365 | 393 | } while($result && !$app_id); |
366 | 394 | } |
367 | - } else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) { |
|
395 | + } |
|
396 | + else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) |
|
397 | + { |
|
368 | 398 | $app = $field; |
369 | 399 | $app_id = $record->$field; |
370 | 400 | |
@@ -425,11 +455,16 @@ discard block |
||
425 | 455 | $fields = $wizard->get_import_fields(); |
426 | 456 | foreach($labels as $field => &$label) |
427 | 457 | { |
428 | - if($fields[$field]) $label = $fields[$field]; |
|
458 | + if($fields[$field]) |
|
459 | + { |
|
460 | + $label = $fields[$field]; |
|
461 | + } |
|
429 | 462 | } |
430 | - } catch (Exception $e) { |
|
463 | + } |
|
464 | + catch (Exception $e) { |
|
431 | 465 | Api\Translation::add_app($definition->application); |
432 | - foreach($labels as $field => &$label) { |
|
466 | + foreach($labels as $field => &$label) |
|
467 | + { |
|
433 | 468 | $label = lang($label); |
434 | 469 | } |
435 | 470 | } |
@@ -468,7 +503,8 @@ discard block |
||
468 | 503 | * @param string $org_name |
469 | 504 | * @return int|boolean Contact ID of first match, or false if none found |
470 | 505 | */ |
471 | - public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) { |
|
506 | + public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) |
|
507 | + { |
|
472 | 508 | |
473 | 509 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
474 | 510 | static $contacts; |
@@ -478,28 +514,40 @@ discard block |
||
478 | 514 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
479 | 515 | } |
480 | 516 | $n_family = trim($n_family); |
481 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
517 | + if(!is_null($n_given)) |
|
518 | + { |
|
519 | + $n_given = trim($n_given); |
|
520 | + } |
|
482 | 521 | if (!is_object($contacts)) |
483 | 522 | { |
484 | 523 | $contacts = new Api\Contacts(); |
485 | 524 | } |
486 | - if (!is_null($org_name)) // org_name given? |
|
525 | + if (!is_null($org_name)) |
|
526 | + { |
|
527 | + // org_name given? |
|
487 | 528 | { |
488 | 529 | $org_name = trim($org_name); |
530 | + } |
|
489 | 531 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
490 | 532 | if (!count($addrs)) |
491 | 533 | { |
492 | 534 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
493 | 535 | } |
494 | 536 | } |
495 | - if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
|
537 | + if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) |
|
538 | + { |
|
539 | + // first name given and no result so far |
|
496 | 540 | { |
497 | 541 | $addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given)); |
498 | 542 | } |
499 | - if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
|
543 | + } |
|
544 | + if (is_null($n_given) && is_null($org_name)) |
|
545 | + { |
|
546 | + // just one name given, check against fn (= full name) |
|
500 | 547 | { |
501 | 548 | $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
502 | 549 | } |
550 | + } |
|
503 | 551 | if (count($addrs)) |
504 | 552 | { |
505 | 553 | if(!$record || !$record->get_identifier()) |
@@ -551,13 +599,17 @@ discard block |
||
551 | 599 | } |
552 | 600 | |
553 | 601 | // Couldn't find field, give an error - something's wrong |
554 | - if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) { |
|
602 | + if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) |
|
603 | + { |
|
555 | 604 | $this->errors[$record_num] .= lang('No custom field "%1" for %2.', |
556 | 605 | $custom_field, lang($app)); |
557 | 606 | return false; |
558 | 607 | } |
559 | - if($custom_field[0] != '#') $custom_field = '#' . $custom_field; |
|
560 | -error_log("Searching for $custom_field = $value"); |
|
608 | + if($custom_field[0] != '#') |
|
609 | + { |
|
610 | + $custom_field = '#' . $custom_field; |
|
611 | + } |
|
612 | + error_log("Searching for $custom_field = $value"); |
|
561 | 613 | // Search |
562 | 614 | if(Link::get_registry($app, 'query')) |
563 | 615 | { |
@@ -591,7 +643,8 @@ discard block |
||
591 | 643 | * |
592 | 644 | * @return string name |
593 | 645 | */ |
594 | - public static function get_name() { |
|
646 | + public static function get_name() |
|
647 | + { |
|
595 | 648 | return lang('Basic CSV import'); |
596 | 649 | } |
597 | 650 | |
@@ -600,7 +653,8 @@ discard block |
||
600 | 653 | * |
601 | 654 | * @return string descriprion |
602 | 655 | */ |
603 | - public static function get_description() { |
|
656 | + public static function get_description() |
|
657 | + { |
|
604 | 658 | return lang("Imports information from a CSV file. This is only a base class, and doesn't do anything on its own."); |
605 | 659 | } |
606 | 660 | |
@@ -609,7 +663,8 @@ discard block |
||
609 | 663 | * |
610 | 664 | * @return string suffix (comma seperated) |
611 | 665 | */ |
612 | - public static function get_filesuffix() { |
|
666 | + public static function get_filesuffix() |
|
667 | + { |
|
613 | 668 | return 'csv'; |
614 | 669 | } |
615 | 670 | |
@@ -625,7 +680,8 @@ discard block |
||
625 | 680 | * preserv => array, |
626 | 681 | * ) |
627 | 682 | */ |
628 | - public function get_options_etpl() { |
|
683 | + public function get_options_etpl() |
|
684 | + { |
|
629 | 685 | // lets do it! |
630 | 686 | } |
631 | 687 | |
@@ -634,7 +690,8 @@ discard block |
||
634 | 690 | * |
635 | 691 | * @return string etemplate name |
636 | 692 | */ |
637 | - public function get_selectors_etpl() { |
|
693 | + public function get_selectors_etpl() |
|
694 | + { |
|
638 | 695 | // lets do it! |
639 | 696 | } |
640 | 697 | |
@@ -646,7 +703,8 @@ discard block |
||
646 | 703 | * record_# => warning message |
647 | 704 | * ) |
648 | 705 | */ |
649 | - public function get_warnings() { |
|
706 | + public function get_warnings() |
|
707 | + { |
|
650 | 708 | return $this->warnings; |
651 | 709 | } |
652 | 710 | |
@@ -658,7 +716,8 @@ discard block |
||
658 | 716 | * record_# => error message |
659 | 717 | * ) |
660 | 718 | */ |
661 | - public function get_errors() { |
|
719 | + public function get_errors() |
|
720 | + { |
|
662 | 721 | return $this->errors; |
663 | 722 | } |
664 | 723 | |
@@ -670,7 +729,8 @@ discard block |
||
670 | 729 | * action => record count |
671 | 730 | * ) |
672 | 731 | */ |
673 | - public function get_results() { |
|
732 | + public function get_results() |
|
733 | + { |
|
674 | 734 | return $this->results; |
675 | 735 | } |
676 | 736 | } // end of iface_export_plugin |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
|
279 | + protected function exists(importexport_iface_egw_record &$record, array &$condition, &$matches = array()) |
|
280 | 280 | { |
281 | 281 | } |
282 | 282 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | - protected function equal(importexport_iface_egw_record &$record, Array &$condition) |
|
291 | + protected function equal(importexport_iface_egw_record &$record, array &$condition) |
|
292 | 292 | { |
293 | 293 | $field = $condition['string']; |
294 | 294 | return $record->$field == $condition['op_2']; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return boolean |
305 | 305 | */ |
306 | - protected function less_than(importexport_iface_egw_record &$record, Array &$condition) |
|
306 | + protected function less_than(importexport_iface_egw_record &$record, array &$condition) |
|
307 | 307 | { |
308 | 308 | $field = $condition['string']; |
309 | 309 | return $record->$field < $condition['op_2']; |