@@ -88,7 +88,10 @@ discard block |
||
| 88 | 88 | // search for plugins with additional filemanager views |
| 89 | 89 | foreach(Api\Hooks::process('filemanager_views') as $views) |
| 90 | 90 | { |
| 91 | - if (is_array($views)) static::$views += $views; |
|
| 91 | + if (is_array($views)) |
|
| 92 | + { |
|
| 93 | + static::$views += $views; |
|
| 94 | + } |
|
| 92 | 95 | } |
| 93 | 96 | static::$views_init = true; |
| 94 | 97 | } |
@@ -396,7 +399,10 @@ discard block |
||
| 396 | 399 | $content['nm']['home_dir'] = static::get_home_dir(); |
| 397 | 400 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
| 398 | 401 | |
| 399 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
| 402 | + if (isset($_GET['msg'])) |
|
| 403 | + { |
|
| 404 | + $msg = $_GET['msg']; |
|
| 405 | + } |
|
| 400 | 406 | |
| 401 | 407 | // Blank favorite set via GET needs special handling for path |
| 402 | 408 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -430,7 +436,10 @@ discard block |
||
| 430 | 436 | // reset lettersearch as it confuses users (they think the dir is empty) |
| 431 | 437 | $content['nm']['searchletter'] = false; |
| 432 | 438 | // switch recusive display off |
| 433 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
| 439 | + if (!$content['nm']['filter']) |
|
| 440 | + { |
|
| 441 | + $content['nm']['filter'] = ''; |
|
| 442 | + } |
|
| 434 | 443 | } |
| 435 | 444 | } |
| 436 | 445 | $view = static::get_view(); |
@@ -479,37 +488,70 @@ discard block |
||
| 479 | 488 | { |
| 480 | 489 | $tpl = new Etemplate('filemanager.index'); |
| 481 | 490 | |
| 482 | - if($msg) Framework::message($msg); |
|
| 491 | + if($msg) |
|
| 492 | + { |
|
| 493 | + Framework::message($msg); |
|
| 494 | + } |
|
| 483 | 495 | |
| 484 | 496 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
| 485 | 497 | { |
| 486 | 498 | if ($content['nm']['action']) |
| 487 | 499 | { |
| 488 | 500 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
| 489 | - if($msg) Framework::message($msg); |
|
| 501 | + if($msg) |
|
| 502 | + { |
|
| 503 | + Framework::message($msg); |
|
| 504 | + } |
|
| 490 | 505 | |
| 491 | 506 | // clean up after action |
| 492 | 507 | unset($content['nm']['selected']); |
| 493 | 508 | // 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 |
| 494 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
| 495 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
| 496 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
| 509 | + if (isset($content['nm']['action'])) |
|
| 510 | + { |
|
| 511 | + unset($content['nm']['action']); |
|
| 512 | + } |
|
| 513 | + if (isset($content['nm']['nm_action'])) |
|
| 514 | + { |
|
| 515 | + unset($content['nm']['nm_action']); |
|
| 516 | + } |
|
| 517 | + if (isset($content['nm_action'])) |
|
| 518 | + { |
|
| 519 | + unset($content['nm_action']); |
|
| 520 | + } |
|
| 497 | 521 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
| 498 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
| 522 | + if (isset($content['nm']['rows']['delete'])) |
|
| 523 | + { |
|
| 524 | + unset($content['nm']['rows']['delete']); |
|
| 525 | + } |
|
| 499 | 526 | } |
| 500 | 527 | elseif($content['nm']['rows']['delete']) |
| 501 | 528 | { |
| 502 | 529 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
| 503 | - if($msg) Framework::message($msg); |
|
| 530 | + if($msg) |
|
| 531 | + { |
|
| 532 | + Framework::message($msg); |
|
| 533 | + } |
|
| 504 | 534 | |
| 505 | 535 | // clean up after action |
| 506 | 536 | unset($content['nm']['rows']['delete']); |
| 507 | 537 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
| 508 | 538 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
| 509 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
| 510 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
| 511 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
| 512 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
| 539 | + if (isset($content['nm']['action'])) |
|
| 540 | + { |
|
| 541 | + unset($content['nm']['action']); |
|
| 542 | + } |
|
| 543 | + if (isset($content['nm']['nm_action'])) |
|
| 544 | + { |
|
| 545 | + unset($content['nm']['nm_action']); |
|
| 546 | + } |
|
| 547 | + if (isset($content['nm_action'])) |
|
| 548 | + { |
|
| 549 | + unset($content['nm_action']); |
|
| 550 | + } |
|
| 551 | + if (isset($content['nm']['selected'])) |
|
| 552 | + { |
|
| 553 | + unset($content['nm']['selected']); |
|
| 554 | + } |
|
| 513 | 555 | } |
| 514 | 556 | unset($content['nm']['rows']); |
| 515 | 557 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -676,9 +718,12 @@ discard block |
||
| 676 | 718 | foreach(Vfs::find($path) as $p) |
| 677 | 719 | { |
| 678 | 720 | $to = $dir.substr($p,$len); |
| 679 | - if ($to == $p) // cant copy into itself! |
|
| 721 | + if ($to == $p) |
|
| 722 | + { |
|
| 723 | + // cant copy into itself! |
|
| 680 | 724 | { |
| 681 | 725 | ++$errs; |
| 726 | + } |
|
| 682 | 727 | continue; |
| 683 | 728 | } |
| 684 | 729 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -733,7 +778,10 @@ discard block |
||
| 733 | 778 | continue; |
| 734 | 779 | } |
| 735 | 780 | } |
| 736 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
| 781 | + if ($target[0] != '/') |
|
| 782 | + { |
|
| 783 | + $target = Vfs::concat($dir, $target); |
|
| 784 | + } |
|
| 737 | 785 | if (!Vfs::stat($target)) |
| 738 | 786 | { |
| 739 | 787 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -776,10 +824,16 @@ discard block |
||
| 776 | 824 | switch($action) |
| 777 | 825 | { |
| 778 | 826 | case 'document': |
| 779 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
| 827 | + if (!$settings) |
|
| 828 | + { |
|
| 829 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
| 830 | + } |
|
| 780 | 831 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
| 781 | 832 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
| 782 | - if($msg) return $msg; |
|
| 833 | + if($msg) |
|
| 834 | + { |
|
| 835 | + return $msg; |
|
| 836 | + } |
|
| 783 | 837 | $errs = count($selected); |
| 784 | 838 | return false; |
| 785 | 839 | } |
@@ -816,7 +870,9 @@ discard block |
||
| 816 | 870 | unset($selected[$key]); |
| 817 | 871 | } |
| 818 | 872 | } |
| 819 | - if ($selected) // somethings left to delete |
|
| 873 | + if ($selected) |
|
| 874 | + { |
|
| 875 | + // somethings left to delete |
|
| 820 | 876 | { |
| 821 | 877 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
| 822 | 878 | foreach((array)$selected as $path) |
@@ -824,6 +880,7 @@ discard block |
||
| 824 | 880 | if (Vfs::isProtectedDir($path)) |
| 825 | 881 | { |
| 826 | 882 | $errs++; |
| 883 | + } |
|
| 827 | 884 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
| 828 | 885 | } |
| 829 | 886 | } |
@@ -872,7 +929,10 @@ discard block |
||
| 872 | 929 | Api\Cache::setSession('filemanager', 'index', |
| 873 | 930 | array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
| 874 | 931 | } |
| 875 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 932 | + if(!$query['path']) |
|
| 933 | + { |
|
| 934 | + $query['path'] = static::get_home_dir(); |
|
| 935 | + } |
|
| 876 | 936 | |
| 877 | 937 | // Change template to match selected view |
| 878 | 938 | if($query['view']) |
@@ -930,7 +990,10 @@ discard block |
||
| 930 | 990 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
| 931 | 991 | |
| 932 | 992 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
| 933 | - if($filter == 5) $maxdepth = 2; |
|
| 993 | + if($filter == 5) |
|
| 994 | + { |
|
| 995 | + $maxdepth = 2; |
|
| 996 | + } |
|
| 934 | 997 | $n = 0; |
| 935 | 998 | $vfs_options = array( |
| 936 | 999 | 'mindepth' => 1, |
@@ -993,10 +1056,16 @@ discard block |
||
| 993 | 1056 | { |
| 994 | 1057 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
| 995 | 1058 | $row =& $rows[$path2n[$path]]; |
| 996 | - if ( !is_array($props) ) continue; |
|
| 1059 | + if ( !is_array($props) ) |
|
| 1060 | + { |
|
| 1061 | + continue; |
|
| 1062 | + } |
|
| 997 | 1063 | foreach($props as $prop) |
| 998 | 1064 | { |
| 999 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
| 1065 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
| 1066 | + { |
|
| 1067 | + continue; |
|
| 1068 | + } |
|
| 1000 | 1069 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
| 1001 | 1070 | } |
| 1002 | 1071 | } |
@@ -1121,7 +1190,10 @@ discard block |
||
| 1121 | 1190 | if (!($dir = Vfs::dirname($path))) |
| 1122 | 1191 | { |
| 1123 | 1192 | $msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false"; |
| 1124 | - if ($button == 'save') $button = 'apply'; |
|
| 1193 | + if ($button == 'save') |
|
| 1194 | + { |
|
| 1195 | + $button = 'apply'; |
|
| 1196 | + } |
|
| 1125 | 1197 | continue; |
| 1126 | 1198 | } |
| 1127 | 1199 | $to = Vfs::concat($dir, $content['name']); |
@@ -1130,7 +1202,10 @@ discard block |
||
| 1130 | 1202 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
| 1131 | 1203 | lang('To overwrite the existing file store again.',lang($button))); |
| 1132 | 1204 | $content['confirm_overwrite'] = $to; |
| 1133 | - if ($button == 'save') $button = 'apply'; |
|
| 1205 | + if ($button == 'save') |
|
| 1206 | + { |
|
| 1207 | + $button = 'apply'; |
|
| 1208 | + } |
|
| 1134 | 1209 | continue; |
| 1135 | 1210 | } |
| 1136 | 1211 | if (Vfs::rename($path,$to)) |
@@ -1203,13 +1278,19 @@ discard block |
||
| 1203 | 1278 | } |
| 1204 | 1279 | if ($ok && !$failed) |
| 1205 | 1280 | { |
| 1206 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1281 | + if(!$perm_changed++) |
|
| 1282 | + { |
|
| 1283 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1284 | + } |
|
| 1207 | 1285 | $content['old'][$name] = $content[$name]; |
| 1208 | 1286 | } |
| 1209 | 1287 | elseif($failed) |
| 1210 | 1288 | { |
| 1211 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1289 | + if(!$perm_failed++) |
|
| 1290 | + { |
|
| 1291 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1212 | 1292 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
| 1293 | + } |
|
| 1213 | 1294 | } |
| 1214 | 1295 | } |
| 1215 | 1296 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1262,7 +1343,10 @@ discard block |
||
| 1262 | 1343 | } |
| 1263 | 1344 | } |
| 1264 | 1345 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
| 1265 | - if ($button == 'save') Framework::window_close(); |
|
| 1346 | + if ($button == 'save') |
|
| 1347 | + { |
|
| 1348 | + Framework::window_close(); |
|
| 1349 | + } |
|
| 1266 | 1350 | } |
| 1267 | 1351 | if ($content['is_link'] && !Vfs::stat($path)) |
| 1268 | 1352 | { |
@@ -1272,13 +1356,19 @@ discard block |
||
| 1272 | 1356 | $content['icon'] = Vfs::mime_icon($content['mime']); |
| 1273 | 1357 | $content['msg'] = $msg; |
| 1274 | 1358 | |
| 1275 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
| 1359 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
| 1360 | + { |
|
| 1361 | + $content['ro_uid_root'] = 'root'; |
|
| 1362 | + } |
|
| 1276 | 1363 | // only owner can change group & perms |
| 1277 | 1364 | if (($readonlys['gid'] = !$content['is_owner'] || |
| 1278 | 1365 | Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs |
| 1279 | 1366 | !Vfs::is_writable($path)) |
| 1280 | 1367 | { |
| 1281 | - if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
|
| 1368 | + if (!$content['gid']) |
|
| 1369 | + { |
|
| 1370 | + $content['ro_gid_root'] = 'root'; |
|
| 1371 | + } |
|
| 1282 | 1372 | foreach($content['perms'] as $name => $value) |
| 1283 | 1373 | { |
| 1284 | 1374 | $readonlys['perms['.$name.']'] = true; |
@@ -1312,9 +1402,13 @@ discard block |
||
| 1312 | 1402 | 5 => lang('Display of content'), |
| 1313 | 1403 | 0 => lang('No access'), |
| 1314 | 1404 | ); |
| 1315 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
| 1405 | + if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) |
|
| 1316 | 1406 | { |
| 1317 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1407 | + // backend supports eacl |
|
| 1408 | + { |
|
| 1409 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
| 1410 | + } |
|
| 1411 | + // --> switch the tab on again |
|
| 1318 | 1412 | foreach($content['eacl'] as &$eacl) |
| 1319 | 1413 | { |
| 1320 | 1414 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1371,10 +1465,13 @@ discard block |
||
| 1371 | 1465 | 'comment' => (string)$content['comment'], |
| 1372 | 1466 | 'mergeapp' => $content['mergeapp'] |
| 1373 | 1467 | ); |
| 1374 | - if ($cfs) foreach($cfs as $name => $data) |
|
| 1468 | + if ($cfs) |
|
| 1469 | + { |
|
| 1470 | + foreach($cfs as $name => $data) |
|
| 1375 | 1471 | { |
| 1376 | 1472 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
| 1377 | 1473 | } |
| 1474 | + } |
|
| 1378 | 1475 | } |
| 1379 | 1476 | if (Vfs::$is_root) |
| 1380 | 1477 | { |
@@ -1401,7 +1498,10 @@ discard block |
||
| 1401 | 1498 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
| 1402 | 1499 | |
| 1403 | 1500 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
| 1404 | - if (true) $tabs = array(); |
|
| 1501 | + if (true) |
|
| 1502 | + { |
|
| 1503 | + $tabs = array(); |
|
| 1504 | + } |
|
| 1405 | 1505 | |
| 1406 | 1506 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
| 1407 | 1507 | { |
@@ -1480,7 +1580,10 @@ discard block |
||
| 1480 | 1580 | 'files' => 0, |
| 1481 | 1581 | ); |
| 1482 | 1582 | |
| 1483 | - if (!isset($dir)) $dir = array_pop($selected); |
|
| 1583 | + if (!isset($dir)) |
|
| 1584 | + { |
|
| 1585 | + $dir = array_pop($selected); |
|
| 1586 | + } |
|
| 1484 | 1587 | |
| 1485 | 1588 | switch($action) |
| 1486 | 1589 | { |
@@ -1560,7 +1663,10 @@ discard block |
||
| 1560 | 1663 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
| 1561 | 1664 | if (Vfs::file_exists($target) && $app_dir) |
| 1562 | 1665 | { |
| 1563 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
| 1666 | + if (!Vfs::file_exists($app_dir)) |
|
| 1667 | + { |
|
| 1668 | + Vfs::mkdir($app_dir); |
|
| 1669 | + } |
|
| 1564 | 1670 | error_log("Symlinking $target to $app_dir"); |
| 1565 | 1671 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
| 1566 | 1672 | } |