@@ -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 | } |
@@ -362,7 +365,10 @@ discard block |
||
| 362 | 365 | $content['nm']['home_dir'] = static::get_home_dir(); |
| 363 | 366 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
| 364 | 367 | |
| 365 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
| 368 | + if (isset($_GET['msg'])) |
|
| 369 | + { |
|
| 370 | + $msg = $_GET['msg']; |
|
| 371 | + } |
|
| 366 | 372 | |
| 367 | 373 | // Blank favorite set via GET needs special handling for path |
| 368 | 374 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -396,7 +402,10 @@ discard block |
||
| 396 | 402 | // reset lettersearch as it confuses users (they think the dir is empty) |
| 397 | 403 | $content['nm']['searchletter'] = false; |
| 398 | 404 | // switch recusive display off |
| 399 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
| 405 | + if (!$content['nm']['filter']) |
|
| 406 | + { |
|
| 407 | + $content['nm']['filter'] = ''; |
|
| 408 | + } |
|
| 400 | 409 | } |
| 401 | 410 | } |
| 402 | 411 | $view = static::get_view(); |
@@ -445,37 +454,70 @@ discard block |
||
| 445 | 454 | { |
| 446 | 455 | $tpl = new Etemplate('filemanager.index'); |
| 447 | 456 | |
| 448 | - if($msg) Framework::message($msg); |
|
| 457 | + if($msg) |
|
| 458 | + { |
|
| 459 | + Framework::message($msg); |
|
| 460 | + } |
|
| 449 | 461 | |
| 450 | 462 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
| 451 | 463 | { |
| 452 | 464 | if ($content['nm']['action']) |
| 453 | 465 | { |
| 454 | 466 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
| 455 | - if($msg) Framework::message($msg); |
|
| 467 | + if($msg) |
|
| 468 | + { |
|
| 469 | + Framework::message($msg); |
|
| 470 | + } |
|
| 456 | 471 | |
| 457 | 472 | // clean up after action |
| 458 | 473 | unset($content['nm']['selected']); |
| 459 | 474 | // 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 |
| 460 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
| 461 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
| 462 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
| 475 | + if (isset($content['nm']['action'])) |
|
| 476 | + { |
|
| 477 | + unset($content['nm']['action']); |
|
| 478 | + } |
|
| 479 | + if (isset($content['nm']['nm_action'])) |
|
| 480 | + { |
|
| 481 | + unset($content['nm']['nm_action']); |
|
| 482 | + } |
|
| 483 | + if (isset($content['nm_action'])) |
|
| 484 | + { |
|
| 485 | + unset($content['nm_action']); |
|
| 486 | + } |
|
| 463 | 487 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
| 464 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
| 488 | + if (isset($content['nm']['rows']['delete'])) |
|
| 489 | + { |
|
| 490 | + unset($content['nm']['rows']['delete']); |
|
| 491 | + } |
|
| 465 | 492 | } |
| 466 | 493 | elseif($content['nm']['rows']['delete']) |
| 467 | 494 | { |
| 468 | 495 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
| 469 | - if($msg) Framework::message($msg); |
|
| 496 | + if($msg) |
|
| 497 | + { |
|
| 498 | + Framework::message($msg); |
|
| 499 | + } |
|
| 470 | 500 | |
| 471 | 501 | // clean up after action |
| 472 | 502 | unset($content['nm']['rows']['delete']); |
| 473 | 503 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
| 474 | 504 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
| 475 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
| 476 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
| 477 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
| 478 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
| 505 | + if (isset($content['nm']['action'])) |
|
| 506 | + { |
|
| 507 | + unset($content['nm']['action']); |
|
| 508 | + } |
|
| 509 | + if (isset($content['nm']['nm_action'])) |
|
| 510 | + { |
|
| 511 | + unset($content['nm']['nm_action']); |
|
| 512 | + } |
|
| 513 | + if (isset($content['nm_action'])) |
|
| 514 | + { |
|
| 515 | + unset($content['nm_action']); |
|
| 516 | + } |
|
| 517 | + if (isset($content['nm']['selected'])) |
|
| 518 | + { |
|
| 519 | + unset($content['nm']['selected']); |
|
| 520 | + } |
|
| 479 | 521 | } |
| 480 | 522 | unset($content['nm']['rows']); |
| 481 | 523 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -639,9 +681,12 @@ discard block |
||
| 639 | 681 | foreach(Vfs::find($path) as $p) |
| 640 | 682 | { |
| 641 | 683 | $to = $dir.substr($p,$len); |
| 642 | - if ($to == $p) // cant copy into itself! |
|
| 684 | + if ($to == $p) |
|
| 685 | + { |
|
| 686 | + // cant copy into itself! |
|
| 643 | 687 | { |
| 644 | 688 | ++$errs; |
| 689 | + } |
|
| 645 | 690 | continue; |
| 646 | 691 | } |
| 647 | 692 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -696,7 +741,10 @@ discard block |
||
| 696 | 741 | continue; |
| 697 | 742 | } |
| 698 | 743 | } |
| 699 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
| 744 | + if ($target[0] != '/') |
|
| 745 | + { |
|
| 746 | + $target = Vfs::concat($dir, $target); |
|
| 747 | + } |
|
| 700 | 748 | if (!Vfs::stat($target)) |
| 701 | 749 | { |
| 702 | 750 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -739,10 +787,16 @@ discard block |
||
| 739 | 787 | switch($action) |
| 740 | 788 | { |
| 741 | 789 | case 'document': |
| 742 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
| 790 | + if (!$settings) |
|
| 791 | + { |
|
| 792 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
| 793 | + } |
|
| 743 | 794 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
| 744 | 795 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
| 745 | - if($msg) return $msg; |
|
| 796 | + if($msg) |
|
| 797 | + { |
|
| 798 | + return $msg; |
|
| 799 | + } |
|
| 746 | 800 | $errs = count($selected); |
| 747 | 801 | return false; |
| 748 | 802 | } |
@@ -779,7 +833,9 @@ discard block |
||
| 779 | 833 | unset($selected[$key]); |
| 780 | 834 | } |
| 781 | 835 | } |
| 782 | - if ($selected) // somethings left to delete |
|
| 836 | + if ($selected) |
|
| 837 | + { |
|
| 838 | + // somethings left to delete |
|
| 783 | 839 | { |
| 784 | 840 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
| 785 | 841 | foreach((array)$selected as $path) |
@@ -787,6 +843,7 @@ discard block |
||
| 787 | 843 | if (Vfs::isProtectedDir($path)) |
| 788 | 844 | { |
| 789 | 845 | $errs++; |
| 846 | + } |
|
| 790 | 847 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
| 791 | 848 | } |
| 792 | 849 | } |
@@ -835,7 +892,10 @@ discard block |
||
| 835 | 892 | Api\Cache::setSession('filemanager', 'index', |
| 836 | 893 | array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
| 837 | 894 | } |
| 838 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 895 | + if(!$query['path']) |
|
| 896 | + { |
|
| 897 | + $query['path'] = static::get_home_dir(); |
|
| 898 | + } |
|
| 839 | 899 | |
| 840 | 900 | // Change template to match selected view |
| 841 | 901 | if($query['view']) |
@@ -893,7 +953,10 @@ discard block |
||
| 893 | 953 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
| 894 | 954 | |
| 895 | 955 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
| 896 | - if($filter == 5) $maxdepth = 2; |
|
| 956 | + if($filter == 5) |
|
| 957 | + { |
|
| 958 | + $maxdepth = 2; |
|
| 959 | + } |
|
| 897 | 960 | $n = 0; |
| 898 | 961 | $vfs_options = array( |
| 899 | 962 | 'mindepth' => 1, |
@@ -955,10 +1018,16 @@ discard block |
||
| 955 | 1018 | { |
| 956 | 1019 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
| 957 | 1020 | $row =& $rows[$path2n[$path]]; |
| 958 | - if ( !is_array($props) ) continue; |
|
| 1021 | + if ( !is_array($props) ) |
|
| 1022 | + { |
|
| 1023 | + continue; |
|
| 1024 | + } |
|
| 959 | 1025 | foreach($props as $prop) |
| 960 | 1026 | { |
| 961 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
| 1027 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
| 1028 | + { |
|
| 1029 | + continue; |
|
| 1030 | + } |
|
| 962 | 1031 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
| 963 | 1032 | } |
| 964 | 1033 | } |
@@ -1083,7 +1152,10 @@ discard block |
||
| 1083 | 1152 | if (!($dir = Vfs::dirname($path))) |
| 1084 | 1153 | { |
| 1085 | 1154 | $msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false"; |
| 1086 | - if ($button == 'save') $button = 'apply'; |
|
| 1155 | + if ($button == 'save') |
|
| 1156 | + { |
|
| 1157 | + $button = 'apply'; |
|
| 1158 | + } |
|
| 1087 | 1159 | continue; |
| 1088 | 1160 | } |
| 1089 | 1161 | $to = Vfs::concat($dir, $content['name']); |
@@ -1092,7 +1164,10 @@ discard block |
||
| 1092 | 1164 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
| 1093 | 1165 | lang('To overwrite the existing file store again.',lang($button))); |
| 1094 | 1166 | $content['confirm_overwrite'] = $to; |
| 1095 | - if ($button == 'save') $button = 'apply'; |
|
| 1167 | + if ($button == 'save') |
|
| 1168 | + { |
|
| 1169 | + $button = 'apply'; |
|
| 1170 | + } |
|
| 1096 | 1171 | continue; |
| 1097 | 1172 | } |
| 1098 | 1173 | if (Vfs::rename($path,$to)) |
@@ -1165,13 +1240,19 @@ discard block |
||
| 1165 | 1240 | } |
| 1166 | 1241 | if ($ok && !$failed) |
| 1167 | 1242 | { |
| 1168 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1243 | + if(!$perm_changed++) |
|
| 1244 | + { |
|
| 1245 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1246 | + } |
|
| 1169 | 1247 | $content['old'][$name] = $content[$name]; |
| 1170 | 1248 | } |
| 1171 | 1249 | elseif($failed) |
| 1172 | 1250 | { |
| 1173 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1251 | + if(!$perm_failed++) |
|
| 1252 | + { |
|
| 1253 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1174 | 1254 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
| 1255 | + } |
|
| 1175 | 1256 | } |
| 1176 | 1257 | } |
| 1177 | 1258 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1224,7 +1305,10 @@ discard block |
||
| 1224 | 1305 | } |
| 1225 | 1306 | } |
| 1226 | 1307 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
| 1227 | - if ($button == 'save') Framework::window_close(); |
|
| 1308 | + if ($button == 'save') |
|
| 1309 | + { |
|
| 1310 | + Framework::window_close(); |
|
| 1311 | + } |
|
| 1228 | 1312 | } |
| 1229 | 1313 | if ($content['is_link'] && !Vfs::stat($path)) |
| 1230 | 1314 | { |
@@ -1234,12 +1318,18 @@ discard block |
||
| 1234 | 1318 | $content['icon'] = Vfs::mime_icon($content['mime']); |
| 1235 | 1319 | $content['msg'] = $msg; |
| 1236 | 1320 | |
| 1237 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
| 1321 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
| 1322 | + { |
|
| 1323 | + $content['ro_uid_root'] = 'root'; |
|
| 1324 | + } |
|
| 1238 | 1325 | // only owner can change group & perms |
| 1239 | 1326 | if (($readonlys['gid'] = !$content['is_owner'] || |
| 1240 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
| 1327 | + Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) |
|
| 1328 | + { |
|
| 1329 | + // no uid, gid or perms in oldvfs |
|
| 1241 | 1330 | { |
| 1242 | 1331 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
| 1332 | + } |
|
| 1243 | 1333 | foreach($content['perms'] as $name => $value) |
| 1244 | 1334 | { |
| 1245 | 1335 | $readonlys['perms['.$name.']'] = true; |
@@ -1272,9 +1362,13 @@ discard block |
||
| 1272 | 1362 | 5 => lang('Display of content'), |
| 1273 | 1363 | 0 => lang('No access'), |
| 1274 | 1364 | ); |
| 1275 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
| 1365 | + if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) |
|
| 1276 | 1366 | { |
| 1277 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1367 | + // backend supports eacl |
|
| 1368 | + { |
|
| 1369 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
| 1370 | + } |
|
| 1371 | + // --> switch the tab on again |
|
| 1278 | 1372 | foreach($content['eacl'] as &$eacl) |
| 1279 | 1373 | { |
| 1280 | 1374 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1331,10 +1425,13 @@ discard block |
||
| 1331 | 1425 | 'comment' => (string)$content['comment'], |
| 1332 | 1426 | 'mergeapp' => $content['mergeapp'] |
| 1333 | 1427 | ); |
| 1334 | - if ($cfs) foreach($cfs as $name => $data) |
|
| 1428 | + if ($cfs) |
|
| 1429 | + { |
|
| 1430 | + foreach($cfs as $name => $data) |
|
| 1335 | 1431 | { |
| 1336 | 1432 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
| 1337 | 1433 | } |
| 1434 | + } |
|
| 1338 | 1435 | } |
| 1339 | 1436 | if (Vfs::$is_root) |
| 1340 | 1437 | { |
@@ -1356,7 +1453,10 @@ discard block |
||
| 1356 | 1453 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
| 1357 | 1454 | |
| 1358 | 1455 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
| 1359 | - if (true) $tabs = array(); |
|
| 1456 | + if (true) |
|
| 1457 | + { |
|
| 1458 | + $tabs = array(); |
|
| 1459 | + } |
|
| 1360 | 1460 | |
| 1361 | 1461 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
| 1362 | 1462 | { |
@@ -1409,7 +1509,10 @@ discard block |
||
| 1409 | 1509 | 'files' => 0, |
| 1410 | 1510 | ); |
| 1411 | 1511 | |
| 1412 | - if (!isset($dir)) $dir = array_pop($selected); |
|
| 1512 | + if (!isset($dir)) |
|
| 1513 | + { |
|
| 1514 | + $dir = array_pop($selected); |
|
| 1515 | + } |
|
| 1413 | 1516 | |
| 1414 | 1517 | switch($action) |
| 1415 | 1518 | { |
@@ -1483,7 +1586,10 @@ discard block |
||
| 1483 | 1586 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
| 1484 | 1587 | if (Vfs::file_exists($target) && $app_dir) |
| 1485 | 1588 | { |
| 1486 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
| 1589 | + if (!Vfs::file_exists($app_dir)) |
|
| 1590 | + { |
|
| 1591 | + Vfs::mkdir($app_dir); |
|
| 1592 | + } |
|
| 1487 | 1593 | error_log("Symlinking $target to $app_dir"); |
| 1488 | 1594 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
| 1489 | 1595 | } |
@@ -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( |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | ), |
| 201 | 201 | // DRAG and DROP events |
| 202 | 202 | 'file_drag' => array( |
| 203 | - 'dragType' => array('file','link'), |
|
| 203 | + 'dragType' => array('file', 'link'), |
|
| 204 | 204 | 'type' => 'drag', |
| 205 | 205 | 'onExecute' => 'javaScript:app.filemanager.drag' |
| 206 | 206 | ), |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | else |
| 241 | 241 | { |
| 242 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
| 242 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
| 243 | 243 | { |
| 244 | 244 | $actions['mail']['children']['mail_'.$mode] = array( |
| 245 | 245 | 'caption' => $data['label'], |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | // This would be done automatically, but we're overriding |
| 252 | - foreach($actions as $action_id => $action) |
|
| 252 | + foreach ($actions as $action_id => $action) |
|
| 253 | 253 | { |
| 254 | - if($action['type'] == 'drop' && $action['caption']) |
|
| 254 | + if ($action['type'] == 'drop' && $action['caption']) |
|
| 255 | 255 | { |
| 256 | 256 | $action['type'] = 'popup'; |
| 257 | - if($action['acceptedTypes'] == 'file') |
|
| 257 | + if ($action['acceptedTypes'] == 'file') |
|
| 258 | 258 | { |
| 259 | 259 | $action['enabled'] = 'javaScript:app.filemanager.paste_enabled'; |
| 260 | 260 | } |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return string merge application or NULL if no property found |
| 276 | 276 | */ |
| 277 | - private static function get_mergeapp($path, $scope='self') |
|
| 277 | + private static function get_mergeapp($path, $scope = 'self') |
|
| 278 | 278 | { |
| 279 | 279 | $app = null; |
| 280 | - switch($scope) |
|
| 280 | + switch ($scope) |
|
| 281 | 281 | { |
| 282 | 282 | case 'self': |
| 283 | 283 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -286,10 +286,10 @@ discard block |
||
| 286 | 286 | case 'parents': |
| 287 | 287 | // search for props in parent directories |
| 288 | 288 | $currentpath = $path; |
| 289 | - while($dir = Vfs::dirname($currentpath)) |
|
| 289 | + while ($dir = Vfs::dirname($currentpath)) |
|
| 290 | 290 | { |
| 291 | 291 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
| 292 | - if(!empty($props)) |
|
| 292 | + if (!empty($props)) |
|
| 293 | 293 | { |
| 294 | 294 | // found prop in parent directory |
| 295 | 295 | return $app = $props[0]['val']; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @param array $content |
| 309 | 309 | * @param string $msg |
| 310 | 310 | */ |
| 311 | - function index(array $content=null,$msg=null) |
|
| 311 | + function index(array $content = null, $msg = null) |
|
| 312 | 312 | { |
| 313 | 313 | if (!is_array($content)) |
| 314 | 314 | { |
@@ -318,16 +318,16 @@ discard block |
||
| 318 | 318 | if (!is_array($content['nm'])) |
| 319 | 319 | { |
| 320 | 320 | $content['nm'] = array( |
| 321 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 322 | - 'filter' => '', // current dir only |
|
| 323 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 324 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 325 | - 'lettersearch' => True, // I show a lettersearch |
|
| 326 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 327 | - 'start' => 0, // IO position in list |
|
| 328 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 329 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 330 | - '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 |
|
| 321 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 322 | + 'filter' => '', // current dir only |
|
| 323 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 324 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 325 | + 'lettersearch' => True, // I show a lettersearch |
|
| 326 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 327 | + 'start' => 0, // IO position in list |
|
| 328 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 329 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 330 | + '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 |
|
| 331 | 331 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
| 332 | 332 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
| 333 | 333 | 'row_id' => 'path', |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | 'parent_id' => 'dir', |
| 336 | 336 | 'is_parent' => 'is_dir', |
| 337 | 337 | 'favorites' => true, |
| 338 | - 'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
| 338 | + 'placeholder_actions' => array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
| 339 | 339 | ); |
| 340 | 340 | $content['nm']['path'] = static::get_home_dir(); |
| 341 | 341 | } |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
| 359 | 359 | { |
| 360 | - switch($path) |
|
| 360 | + switch ($path) |
|
| 361 | 361 | { |
| 362 | 362 | case '..': |
| 363 | 363 | $path = Vfs::dirname($content['nm']['path']); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | $path = static::get_home_dir(); |
| 367 | 367 | break; |
| 368 | 368 | } |
| 369 | - if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
| 369 | + if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
| 370 | 370 | { |
| 371 | 371 | $content['nm']['path'] = $path; |
| 372 | 372 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | $view = static::get_view(); |
| 384 | 384 | |
| 385 | - call_user_func($view,$content,$msg); |
|
| 385 | + call_user_func($view, $content, $msg); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
| 396 | 396 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
| 397 | 397 | */ |
| 398 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
| 398 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
| 399 | 399 | { |
| 400 | 400 | if (!$user) |
| 401 | 401 | { |
@@ -404,15 +404,15 @@ discard block |
||
| 404 | 404 | else |
| 405 | 405 | { |
| 406 | 406 | // config user & password |
| 407 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
| 407 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
| 408 | 408 | // or vfs root user from setup >> configuration |
| 409 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
| 410 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
| 409 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
| 410 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
| 411 | 411 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
| 412 | 412 | } |
| 413 | 413 | //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)); |
| 414 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
| 415 | - Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
| 414 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
| 415 | + Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
| 416 | 416 | return Vfs::$is_root; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -422,18 +422,18 @@ discard block |
||
| 422 | 422 | * @param array $content |
| 423 | 423 | * @param string $msg |
| 424 | 424 | */ |
| 425 | - function listview(array $content=null,$msg=null) |
|
| 425 | + function listview(array $content = null, $msg = null) |
|
| 426 | 426 | { |
| 427 | 427 | $tpl = new Etemplate('filemanager.index'); |
| 428 | 428 | |
| 429 | - if($msg) Framework::message($msg); |
|
| 429 | + if ($msg) Framework::message($msg); |
|
| 430 | 430 | |
| 431 | 431 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
| 432 | 432 | { |
| 433 | 433 | if ($content['nm']['action']) |
| 434 | 434 | { |
| 435 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
| 436 | - if($msg) Framework::message($msg); |
|
| 435 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
| 436 | + if ($msg) Framework::message($msg); |
|
| 437 | 437 | |
| 438 | 438 | // clean up after action |
| 439 | 439 | unset($content['nm']['selected']); |
@@ -444,10 +444,10 @@ discard block |
||
| 444 | 444 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
| 445 | 445 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
| 446 | 446 | } |
| 447 | - elseif($content['nm']['rows']['delete']) |
|
| 447 | + elseif ($content['nm']['rows']['delete']) |
|
| 448 | 448 | { |
| 449 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
| 450 | - if($msg) Framework::message($msg); |
|
| 449 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
| 450 | + if ($msg) Framework::message($msg); |
|
| 451 | 451 | |
| 452 | 452 | // clean up after action |
| 453 | 453 | unset($content['nm']['rows']['delete']); |
@@ -459,11 +459,11 @@ discard block |
||
| 459 | 459 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
| 460 | 460 | } |
| 461 | 461 | unset($content['nm']['rows']); |
| 462 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
| 462 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // be tolerant with (in previous versions) not correct urlencoded pathes |
| 466 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
| 466 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
| 467 | 467 | { |
| 468 | 468 | $content['nm']['path'] = urldecode($content['nm']['path']); |
| 469 | 469 | } |
@@ -474,22 +474,22 @@ discard block |
||
| 474 | 474 | list($button) = each($content['button']); |
| 475 | 475 | unset($content['button']); |
| 476 | 476 | } |
| 477 | - switch($button) |
|
| 477 | + switch ($button) |
|
| 478 | 478 | { |
| 479 | 479 | case 'upload': |
| 480 | 480 | if (!$content['upload']) |
| 481 | 481 | { |
| 482 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
| 482 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
| 483 | 483 | break; |
| 484 | 484 | } |
| 485 | 485 | $upload_success = $upload_failure = array(); |
| 486 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
| 486 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
| 487 | 487 | { |
| 488 | 488 | // encode chars which special meaning in url/vfs (some like / get removed!) |
| 489 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
| 489 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
| 490 | 490 | if ($upload && |
| 491 | 491 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
| 492 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
| 492 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
| 493 | 493 | { |
| 494 | 494 | $upload_success[] = $upload['name']; |
| 495 | 495 | } |
@@ -501,12 +501,11 @@ discard block |
||
| 501 | 501 | $content['nm']['msg'] = ''; |
| 502 | 502 | if ($upload_success) |
| 503 | 503 | { |
| 504 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
| 505 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
| 504 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
| 506 | 505 | } |
| 507 | 506 | if ($upload_failure) |
| 508 | 507 | { |
| 509 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
| 508 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
| 510 | 509 | } |
| 511 | 510 | break; |
| 512 | 511 | } |
@@ -527,16 +526,16 @@ discard block |
||
| 527 | 526 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
| 528 | 527 | } |
| 529 | 528 | // Set view button to match current settings |
| 530 | - if($content['nm']['view'] == 'tile') |
|
| 529 | + if ($content['nm']['view'] == 'tile') |
|
| 531 | 530 | { |
| 532 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
| 533 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
| 531 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
| 532 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
| 534 | 533 | } |
| 535 | 534 | // if initial load is done via GET request (idots template or share.php) |
| 536 | 535 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
| 537 | 536 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
| 538 | 537 | |
| 539 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
| 538 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
| 540 | 539 | } |
| 541 | 540 | |
| 542 | 541 | /** |
@@ -572,7 +571,7 @@ discard block |
||
| 572 | 571 | * @param int &$files=null on return number of files deleted |
| 573 | 572 | * @return string success or failure message displayed to the user |
| 574 | 573 | */ |
| 575 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
| 574 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
| 576 | 575 | { |
| 577 | 576 | if (!count($selected)) |
| 578 | 577 | { |
@@ -580,20 +579,20 @@ discard block |
||
| 580 | 579 | } |
| 581 | 580 | $errs = $dirs = $files = 0; |
| 582 | 581 | |
| 583 | - switch($action) |
|
| 582 | + switch ($action) |
|
| 584 | 583 | { |
| 585 | 584 | |
| 586 | 585 | case 'delete': |
| 587 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
| 586 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
| 588 | 587 | |
| 589 | 588 | case 'mail': |
| 590 | 589 | case 'copy': |
| 591 | - foreach($selected as $path) |
|
| 590 | + foreach ($selected as $path) |
|
| 592 | 591 | { |
| 593 | 592 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
| 594 | 593 | { |
| 595 | 594 | // Support for dropping mail in filemanager - Pass mail back to mail app |
| 596 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
| 595 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
| 597 | 596 | { |
| 598 | 597 | ++$files; |
| 599 | 598 | } |
@@ -604,8 +603,8 @@ discard block |
||
| 604 | 603 | } |
| 605 | 604 | elseif (!Vfs::is_dir($path)) |
| 606 | 605 | { |
| 607 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
| 608 | - if ($path != $to && Vfs::copy($path,$to)) |
|
| 606 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
| 607 | + if ($path != $to && Vfs::copy($path, $to)) |
|
| 609 | 608 | { |
| 610 | 609 | ++$files; |
| 611 | 610 | } |
@@ -617,19 +616,19 @@ discard block |
||
| 617 | 616 | else |
| 618 | 617 | { |
| 619 | 618 | $len = strlen(dirname($path)); |
| 620 | - foreach(Vfs::find($path) as $p) |
|
| 619 | + foreach (Vfs::find($path) as $p) |
|
| 621 | 620 | { |
| 622 | - $to = $dir.substr($p,$len); |
|
| 621 | + $to = $dir.substr($p, $len); |
|
| 623 | 622 | if ($to == $p) // cant copy into itself! |
| 624 | 623 | { |
| 625 | 624 | ++$errs; |
| 626 | 625 | continue; |
| 627 | 626 | } |
| 628 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
| 627 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
| 629 | 628 | { |
| 630 | 629 | ++$dirs; |
| 631 | 630 | } |
| 632 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
| 631 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
| 633 | 632 | { |
| 634 | 633 | ++$files; |
| 635 | 634 | } |
@@ -642,15 +641,15 @@ discard block |
||
| 642 | 641 | } |
| 643 | 642 | if ($errs) |
| 644 | 643 | { |
| 645 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
| 644 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
| 646 | 645 | } |
| 647 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
| 646 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
| 648 | 647 | |
| 649 | 648 | case 'move': |
| 650 | - foreach($selected as $path) |
|
| 649 | + foreach ($selected as $path) |
|
| 651 | 650 | { |
| 652 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
| 653 | - if ($path != $to && Vfs::rename($path,$to)) |
|
| 651 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
| 652 | + if ($path != $to && Vfs::rename($path, $to)) |
|
| 654 | 653 | { |
| 655 | 654 | ++$files; |
| 656 | 655 | } |
@@ -661,17 +660,17 @@ discard block |
||
| 661 | 660 | } |
| 662 | 661 | if ($errs) |
| 663 | 662 | { |
| 664 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
| 663 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
| 665 | 664 | } |
| 666 | - return lang('%1 files moved.',$files); |
|
| 665 | + return lang('%1 files moved.', $files); |
|
| 667 | 666 | |
| 668 | 667 | case 'symlink': // symlink given files to $dir |
| 669 | - foreach((array)$selected as $target) |
|
| 668 | + foreach ((array)$selected as $target) |
|
| 670 | 669 | { |
| 671 | 670 | $link = Vfs::concat($dir, Vfs::basename($target)); |
| 672 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
| 671 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
| 673 | 672 | { |
| 674 | - if(!$ok) |
|
| 673 | + if (!$ok) |
|
| 675 | 674 | { |
| 676 | 675 | $errs++; |
| 677 | 676 | continue; |
@@ -693,15 +692,14 @@ discard block |
||
| 693 | 692 | } |
| 694 | 693 | if (count((array)$selected) == 1) |
| 695 | 694 | { |
| 696 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
| 697 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
| 695 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
| 698 | 696 | } |
| 699 | 697 | $ret = lang('%1 elements linked.', $files); |
| 700 | 698 | if ($errs) |
| 701 | 699 | { |
| 702 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
| 700 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
| 703 | 701 | } |
| 704 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
| 702 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
| 705 | 703 | |
| 706 | 704 | case 'createdir': |
| 707 | 705 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -717,13 +715,13 @@ discard block |
||
| 717 | 715 | |
| 718 | 716 | default: |
| 719 | 717 | list($action, $settings) = explode('_', $action, 2); |
| 720 | - switch($action) |
|
| 718 | + switch ($action) |
|
| 721 | 719 | { |
| 722 | 720 | case 'document': |
| 723 | 721 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
| 724 | 722 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
| 725 | 723 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
| 726 | - if($msg) return $msg; |
|
| 724 | + if ($msg) return $msg; |
|
| 727 | 725 | $errs = count($selected); |
| 728 | 726 | return false; |
| 729 | 727 | } |
@@ -740,12 +738,12 @@ discard block |
||
| 740 | 738 | * @param int &$files=null on return number of files deleted |
| 741 | 739 | * @return string |
| 742 | 740 | */ |
| 743 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
| 741 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
| 744 | 742 | { |
| 745 | 743 | $dirs = $files = $errs = 0; |
| 746 | 744 | // we first delete all selected links (and files) |
| 747 | 745 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
| 748 | - foreach($selected as $key => $path) |
|
| 746 | + foreach ($selected as $key => $path) |
|
| 749 | 747 | { |
| 750 | 748 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
| 751 | 749 | { |
@@ -763,21 +761,21 @@ discard block |
||
| 763 | 761 | if ($selected) // somethings left to delete |
| 764 | 762 | { |
| 765 | 763 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
| 766 | - foreach((array)$selected as $path) |
|
| 764 | + foreach ((array)$selected as $path) |
|
| 767 | 765 | { |
| 768 | 766 | if (Vfs::isProtectedDir($path)) |
| 769 | 767 | { |
| 770 | 768 | $errs++; |
| 771 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
| 769 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
| 772 | 770 | } |
| 773 | 771 | } |
| 774 | 772 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
| 775 | 773 | // - depth=true to get first the files and then the dir containing it |
| 776 | 774 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
| 777 | 775 | // - show-deleted=false to not (finally) deleted versioned files |
| 778 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
| 776 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
| 779 | 777 | { |
| 780 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
| 778 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
| 781 | 779 | { |
| 782 | 780 | ++$dirs; |
| 783 | 781 | } |
@@ -793,13 +791,13 @@ discard block |
||
| 793 | 791 | } |
| 794 | 792 | if ($errs) |
| 795 | 793 | { |
| 796 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
| 794 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
| 797 | 795 | } |
| 798 | 796 | if ($dirs) |
| 799 | 797 | { |
| 800 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
| 798 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
| 801 | 799 | } |
| 802 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
| 800 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
| 803 | 801 | } |
| 804 | 802 | |
| 805 | 803 | /** |
@@ -814,37 +812,37 @@ discard block |
||
| 814 | 812 | if (!$query['csv_export']) |
| 815 | 813 | { |
| 816 | 814 | Api\Cache::setSession('filemanager', 'index', |
| 817 | - array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
|
| 815 | + array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
| 818 | 816 | } |
| 819 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 817 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 820 | 818 | |
| 821 | 819 | // Change template to match selected view |
| 822 | - if($query['view']) |
|
| 820 | + if ($query['view']) |
|
| 823 | 821 | { |
| 824 | 822 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
| 825 | 823 | |
| 826 | 824 | // Store as preference but only for index, not home |
| 827 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
| 825 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
| 828 | 826 | { |
| 829 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
| 827 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
| 830 | 828 | $GLOBALS['egw']->preferences->save_repository(); |
| 831 | 829 | } |
| 832 | 830 | } |
| 833 | 831 | // be tolerant with (in previous versions) not correct urlencoded pathes |
| 834 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
| 832 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
| 835 | 833 | { |
| 836 | 834 | $query['path'] = urldecode($query['path']); |
| 837 | 835 | } |
| 838 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
| 836 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
| 839 | 837 | { |
| 840 | 838 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
| 841 | 839 | if ($query['path'] != ($path = static::get_home_dir())) |
| 842 | 840 | { |
| 843 | 841 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
| 844 | 842 | // an appropriate message |
| 845 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
| 843 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
| 846 | 844 | 'path' => $path, |
| 847 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
| 845 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
| 848 | 846 | 'ajax' => 'true' |
| 849 | 847 | )); |
| 850 | 848 | } |
@@ -852,35 +850,35 @@ discard block |
||
| 852 | 850 | return 0; |
| 853 | 851 | } |
| 854 | 852 | $rows = $dir_is_writable = array(); |
| 855 | - if($query['searchletter'] && !empty($query['search'])) |
|
| 853 | + if ($query['searchletter'] && !empty($query['search'])) |
|
| 856 | 854 | { |
| 857 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
| 855 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
| 858 | 856 | if ($query['searchletter'] == strtolower($query['search'][0])) |
| 859 | 857 | { |
| 860 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
| 861 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
| 858 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
| 859 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
| 862 | 860 | } |
| 863 | 861 | } |
| 864 | 862 | elseif ($query['searchletter']) |
| 865 | 863 | { |
| 866 | 864 | $namefilter = '/^'.$query['searchletter'].'/i'; |
| 867 | 865 | } |
| 868 | - elseif(!empty($query['search'])) |
|
| 866 | + elseif (!empty($query['search'])) |
|
| 869 | 867 | { |
| 870 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
| 868 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
| 871 | 869 | } |
| 872 | 870 | |
| 873 | 871 | // Re-map so 'No filters' favorite ('') is depth 1 |
| 874 | 872 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
| 875 | 873 | |
| 876 | 874 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
| 877 | - if($filter == 5) $maxdepth = 2; |
|
| 875 | + if ($filter == 5) $maxdepth = 2; |
|
| 878 | 876 | $n = 0; |
| 879 | 877 | $vfs_options = array( |
| 880 | 878 | 'mindepth' => 1, |
| 881 | 879 | 'maxdepth' => $maxdepth, |
| 882 | 880 | 'dirsontop' => $filter <= 1, |
| 883 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
| 881 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
| 884 | 882 | 'order' => $query['order'], 'sort' => $query['sort'], |
| 885 | 883 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
| 886 | 884 | 'need_mime' => true, |
@@ -888,11 +886,11 @@ discard block |
||
| 888 | 886 | 'hidden' => $filter == 3, |
| 889 | 887 | 'follow' => $filter == 5, |
| 890 | 888 | ); |
| 891 | - if($query['col_filter']['mime']) |
|
| 889 | + if ($query['col_filter']['mime']) |
|
| 892 | 890 | { |
| 893 | 891 | $vfs_options['mime'] = $query['col_filter']['mime']; |
| 894 | 892 | } |
| 895 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
| 893 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
| 896 | 894 | { |
| 897 | 895 | //echo $path; _debug_array($row); |
| 898 | 896 | |
@@ -907,7 +905,7 @@ discard block |
||
| 907 | 905 | { |
| 908 | 906 | $dir_is_writable[$path] = Vfs::is_writable($path); |
| 909 | 907 | } |
| 910 | - if(!$dir_is_writable[$path]) |
|
| 908 | + if (!$dir_is_writable[$path]) |
|
| 911 | 909 | { |
| 912 | 910 | $row['class'] .= 'noEdit '; |
| 913 | 911 | } |
@@ -915,32 +913,32 @@ discard block |
||
| 915 | 913 | $row['is_dir'] = 1; |
| 916 | 914 | } |
| 917 | 915 | $row['download_url'] = Vfs::download_url($path); |
| 918 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
| 916 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
| 919 | 917 | |
| 920 | 918 | $rows[++$n] = $row; |
| 921 | 919 | $path2n[$path] = $n; |
| 922 | 920 | } |
| 923 | 921 | // query comments and cf's for the displayed rows |
| 924 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
| 922 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
| 925 | 923 | |
| 926 | 924 | // Always include comment in tiles |
| 927 | - if($query['view'] == 'tile') |
|
| 925 | + if ($query['view'] == 'tile') |
|
| 928 | 926 | { |
| 929 | 927 | $cols_to_show[] = 'comment'; |
| 930 | 928 | } |
| 931 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
| 932 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
| 929 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
| 930 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
| 933 | 931 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
| 934 | 932 | { |
| 935 | - foreach($path2props as $path => $props) |
|
| 933 | + foreach ($path2props as $path => $props) |
|
| 936 | 934 | { |
| 937 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
| 938 | - $row =& $rows[$path2n[$path]]; |
|
| 939 | - if ( !is_array($props) ) continue; |
|
| 940 | - foreach($props as $prop) |
|
| 935 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
| 936 | + $row = & $rows[$path2n[$path]]; |
|
| 937 | + if (!is_array($props)) continue; |
|
| 938 | + foreach ($props as $prop) |
|
| 941 | 939 | { |
| 942 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
| 943 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
| 940 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
| 941 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
| 944 | 942 | } |
| 945 | 943 | } |
| 946 | 944 | } |
@@ -952,7 +950,7 @@ discard block |
||
| 952 | 950 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
| 953 | 951 | { |
| 954 | 952 | // we need our app.css file |
| 955 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
| 953 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
| 956 | 954 | { |
| 957 | 955 | $css_file = '/filemanager/templates/default/app.css'; |
| 958 | 956 | } |
@@ -968,7 +966,7 @@ discard block |
||
| 968 | 966 | * @param array $content |
| 969 | 967 | * @param string $msg |
| 970 | 968 | */ |
| 971 | - function file(array $content=null,$msg='') |
|
| 969 | + function file(array $content = null, $msg = '') |
|
| 972 | 970 | { |
| 973 | 971 | $tpl = new Etemplate('filemanager.file'); |
| 974 | 972 | |
@@ -978,9 +976,9 @@ discard block |
||
| 978 | 976 | { |
| 979 | 977 | $msg .= $_GET['msg']; |
| 980 | 978 | } |
| 981 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
| 979 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
| 982 | 980 | // actions enclose pathes containing comma with " |
| 983 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
| 981 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
| 984 | 982 | !($stat = Vfs::lstat($path))) |
| 985 | 983 | { |
| 986 | 984 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -993,10 +991,10 @@ discard block |
||
| 993 | 991 | $content['path'] = $path; |
| 994 | 992 | $content['hsize'] = Vfs::hsize($stat['size']); |
| 995 | 993 | $content['mime'] = Vfs::mime_content_type($path); |
| 996 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
| 994 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
| 997 | 995 | if (($props = Vfs::propfind($path))) |
| 998 | 996 | { |
| 999 | - foreach($props as $prop) |
|
| 997 | + foreach ($props as $prop) |
|
| 1000 | 998 | { |
| 1001 | 999 | $content[$prop['name']] = $prop['val']; |
| 1002 | 1000 | } |
@@ -1009,9 +1007,9 @@ discard block |
||
| 1009 | 1007 | $content['tabs'] = $_GET['tabs']; |
| 1010 | 1008 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
| 1011 | 1009 | { |
| 1012 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
| 1010 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
| 1013 | 1011 | $mask = 6; |
| 1014 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
| 1012 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
| 1015 | 1013 | { |
| 1016 | 1014 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
| 1017 | 1015 | } |
@@ -1021,19 +1019,19 @@ discard block |
||
| 1021 | 1019 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
| 1022 | 1020 | $mask = 7; |
| 1023 | 1021 | } |
| 1024 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
| 1022 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
| 1025 | 1023 | { |
| 1026 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
| 1024 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
| 1027 | 1025 | } |
| 1028 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
| 1026 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
| 1029 | 1027 | } |
| 1030 | 1028 | else |
| 1031 | 1029 | { |
| 1032 | 1030 | //_debug_array($content); |
| 1033 | - $path =& $content['path']; |
|
| 1031 | + $path = & $content['path']; |
|
| 1034 | 1032 | |
| 1035 | 1033 | list($button) = @each($content['button']); unset($content['button']); |
| 1036 | - if(!$button && $content['sudo']) |
|
| 1034 | + if (!$button && $content['sudo']) |
|
| 1037 | 1035 | { |
| 1038 | 1036 | // Button to stop sudo is not in button namespace |
| 1039 | 1037 | $button = 'sudo'; |
@@ -1042,21 +1040,21 @@ discard block |
||
| 1042 | 1040 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
| 1043 | 1041 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
| 1044 | 1042 | { |
| 1045 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
| 1043 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
| 1046 | 1044 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
| 1047 | 1045 | lang('Wrong username or password!') : lang('Root access stopped.')); |
| 1048 | 1046 | unset($content['sudo']); |
| 1049 | 1047 | $content['is_owner'] = Vfs::has_owner_rights($path); |
| 1050 | 1048 | } |
| 1051 | - if (in_array($button,array('save','apply'))) |
|
| 1049 | + if (in_array($button, array('save', 'apply'))) |
|
| 1052 | 1050 | { |
| 1053 | 1051 | $props = array(); |
| 1054 | 1052 | $perm_changed = $perm_failed = 0; |
| 1055 | - foreach($content['old'] as $name => $old_value) |
|
| 1053 | + foreach ($content['old'] as $name => $old_value) |
|
| 1056 | 1054 | { |
| 1057 | 1055 | if (isset($content[$name]) && ($old_value != $content[$name] || |
| 1058 | 1056 | // do not check for modification, if modify_subs is checked! |
| 1059 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
| 1057 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
| 1060 | 1058 | ($name != 'uid' || Vfs::$is_root)) |
| 1061 | 1059 | { |
| 1062 | 1060 | if ($name == 'name') |
@@ -1070,23 +1068,23 @@ discard block |
||
| 1070 | 1068 | $to = Vfs::concat($dir, $content['name']); |
| 1071 | 1069 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
| 1072 | 1070 | { |
| 1073 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
| 1074 | - lang('To overwrite the existing file store again.',lang($button))); |
|
| 1071 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
| 1072 | + lang('To overwrite the existing file store again.', lang($button))); |
|
| 1075 | 1073 | $content['confirm_overwrite'] = $to; |
| 1076 | 1074 | if ($button == 'save') $button = 'apply'; |
| 1077 | 1075 | continue; |
| 1078 | 1076 | } |
| 1079 | - if (Vfs::rename($path,$to)) |
|
| 1077 | + if (Vfs::rename($path, $to)) |
|
| 1080 | 1078 | { |
| 1081 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
| 1079 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
| 1082 | 1080 | $content['old']['name'] = $content[$name]; |
| 1083 | 1081 | $path = $to; |
| 1084 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
| 1085 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
| 1082 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
| 1083 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
| 1086 | 1084 | } |
| 1087 | 1085 | else |
| 1088 | 1086 | { |
| 1089 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
| 1087 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
| 1090 | 1088 | if (Vfs::deny_script($to)) |
| 1091 | 1089 | { |
| 1092 | 1090 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1106,7 +1104,7 @@ discard block |
||
| 1106 | 1104 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
| 1107 | 1105 | ), |
| 1108 | 1106 | ); |
| 1109 | - if (Vfs::proppatch($path,$mergeprop)) |
|
| 1107 | + if (Vfs::proppatch($path, $mergeprop)) |
|
| 1110 | 1108 | { |
| 1111 | 1109 | $content['old'][$name] = $content[$name]; |
| 1112 | 1110 | $msg .= lang('Setting for document merge saved.'); |
@@ -1118,22 +1116,22 @@ discard block |
||
| 1118 | 1116 | } |
| 1119 | 1117 | else |
| 1120 | 1118 | { |
| 1121 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
| 1122 | - $cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]); |
|
| 1119 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
| 1120 | + $cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]); |
|
| 1123 | 1121 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
| 1124 | 1122 | if ($content['modify_subs']) |
| 1125 | 1123 | { |
| 1126 | 1124 | if ($name == 'perms') |
| 1127 | 1125 | { |
| 1128 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
| 1129 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
| 1126 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
| 1127 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
| 1130 | 1128 | } |
| 1131 | 1129 | else |
| 1132 | 1130 | { |
| 1133 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
| 1131 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
| 1134 | 1132 | } |
| 1135 | 1133 | $ok = $failed = 0; |
| 1136 | - foreach($changed as &$r) |
|
| 1134 | + foreach ($changed as &$r) |
|
| 1137 | 1135 | { |
| 1138 | 1136 | if ($r) |
| 1139 | 1137 | { |
@@ -1146,32 +1144,32 @@ discard block |
||
| 1146 | 1144 | } |
| 1147 | 1145 | if ($ok && !$failed) |
| 1148 | 1146 | { |
| 1149 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1147 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
| 1150 | 1148 | $content['old'][$name] = $content[$name]; |
| 1151 | 1149 | } |
| 1152 | - elseif($failed) |
|
| 1150 | + elseif ($failed) |
|
| 1153 | 1151 | { |
| 1154 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1155 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
| 1152 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
| 1153 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
| 1156 | 1154 | } |
| 1157 | 1155 | } |
| 1158 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
| 1156 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
| 1159 | 1157 | { |
| 1160 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
| 1158 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
| 1161 | 1159 | $content['old'][$name] = $content[$name]; |
| 1162 | 1160 | } |
| 1163 | 1161 | else |
| 1164 | 1162 | { |
| 1165 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
| 1163 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
| 1166 | 1164 | } |
| 1167 | 1165 | } |
| 1168 | 1166 | } |
| 1169 | 1167 | } |
| 1170 | 1168 | if ($props) |
| 1171 | 1169 | { |
| 1172 | - if (Vfs::proppatch($path,$props)) |
|
| 1170 | + if (Vfs::proppatch($path, $props)) |
|
| 1173 | 1171 | { |
| 1174 | - foreach($props as $prop) |
|
| 1172 | + foreach ($props as $prop) |
|
| 1175 | 1173 | { |
| 1176 | 1174 | $content['old'][$prop['name']] = $prop['val']; |
| 1177 | 1175 | } |
@@ -1188,8 +1186,8 @@ discard block |
||
| 1188 | 1186 | if ($content['eacl']['delete']) |
| 1189 | 1187 | { |
| 1190 | 1188 | list($ino_owner) = each($content['eacl']['delete']); |
| 1191 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
| 1192 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
| 1189 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
| 1190 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
| 1193 | 1191 | } |
| 1194 | 1192 | elseif ($button == 'eacl') |
| 1195 | 1193 | { |
@@ -1199,7 +1197,7 @@ discard block |
||
| 1199 | 1197 | } |
| 1200 | 1198 | else |
| 1201 | 1199 | { |
| 1202 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
| 1200 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
| 1203 | 1201 | lang('ACL added.') : lang('Error adding the ACL!'); |
| 1204 | 1202 | } |
| 1205 | 1203 | } |
@@ -1209,7 +1207,7 @@ discard block |
||
| 1209 | 1207 | } |
| 1210 | 1208 | if ($content['is_link'] && !Vfs::stat($path)) |
| 1211 | 1209 | { |
| 1212 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
| 1210 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
| 1213 | 1211 | } |
| 1214 | 1212 | $content['link'] = Egw::link(Vfs::download_url($path)); |
| 1215 | 1213 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1218,10 +1216,10 @@ discard block |
||
| 1218 | 1216 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
| 1219 | 1217 | // only owner can change group & perms |
| 1220 | 1218 | if (($readonlys['gid'] = !$content['is_owner'] || |
| 1221 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
| 1219 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
| 1222 | 1220 | { |
| 1223 | 1221 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
| 1224 | - foreach($content['perms'] as $name => $value) |
|
| 1222 | + foreach ($content['perms'] as $name => $value) |
|
| 1225 | 1223 | { |
| 1226 | 1224 | $readonlys['perms['.$name.']'] = true; |
| 1227 | 1225 | } |
@@ -1239,37 +1237,37 @@ discard block |
||
| 1239 | 1237 | } |
| 1240 | 1238 | elseif (!Vfs::is_writable($path)) |
| 1241 | 1239 | { |
| 1242 | - foreach($cfs as $name => $data) |
|
| 1240 | + foreach ($cfs as $name => $data) |
|
| 1243 | 1241 | { |
| 1244 | 1242 | $readonlys['#'.$name] = true; |
| 1245 | 1243 | } |
| 1246 | 1244 | } |
| 1247 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
| 1245 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
| 1248 | 1246 | if ($content['is_dir']) |
| 1249 | 1247 | { |
| 1250 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
| 1251 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
| 1248 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
| 1249 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
| 1252 | 1250 | 7 => lang('Display and modification of content'), |
| 1253 | 1251 | 5 => lang('Display of content'), |
| 1254 | 1252 | 0 => lang('No access'), |
| 1255 | 1253 | ); |
| 1256 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
| 1254 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
| 1257 | 1255 | { |
| 1258 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1259 | - foreach($content['eacl'] as &$eacl) |
|
| 1256 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1257 | + foreach ($content['eacl'] as &$eacl) |
|
| 1260 | 1258 | { |
| 1261 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
| 1259 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
| 1262 | 1260 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
| 1263 | 1261 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
| 1264 | 1262 | } |
| 1265 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
| 1263 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
| 1266 | 1264 | $content['eacl']['owner'] = 0; |
| 1267 | 1265 | $content['eacl']['rights'] = 5; |
| 1268 | 1266 | } |
| 1269 | 1267 | } |
| 1270 | 1268 | else |
| 1271 | 1269 | { |
| 1272 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
| 1270 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
| 1273 | 1271 | 6 => lang('Read & write access'), |
| 1274 | 1272 | 4 => lang('Read access only'), |
| 1275 | 1273 | 0 => lang('No access'), |
@@ -1279,11 +1277,11 @@ discard block |
||
| 1279 | 1277 | // mergeapp |
| 1280 | 1278 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
| 1281 | 1279 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
| 1282 | - if(!empty($content['mergeapp'])) |
|
| 1280 | + if (!empty($content['mergeapp'])) |
|
| 1283 | 1281 | { |
| 1284 | 1282 | $content['mergeapp_effective'] = $content['mergeapp']; |
| 1285 | 1283 | } |
| 1286 | - elseif(!empty($content['mergeapp_parent'])) |
|
| 1284 | + elseif (!empty($content['mergeapp_parent'])) |
|
| 1287 | 1285 | { |
| 1288 | 1286 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
| 1289 | 1287 | } |
@@ -1295,7 +1293,7 @@ discard block |
||
| 1295 | 1293 | $mergeapp_list = Link::app_list('merge'); |
| 1296 | 1294 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
| 1297 | 1295 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
| 1298 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
| 1296 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
| 1299 | 1297 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
| 1300 | 1298 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
| 1301 | 1299 | // mergeapp other gui options |
@@ -1312,7 +1310,7 @@ discard block |
||
| 1312 | 1310 | 'comment' => (string)$content['comment'], |
| 1313 | 1311 | 'mergeapp' => $content['mergeapp'] |
| 1314 | 1312 | ); |
| 1315 | - if ($cfs) foreach($cfs as $name => $data) |
|
| 1313 | + if ($cfs) foreach ($cfs as $name => $data) |
|
| 1316 | 1314 | { |
| 1317 | 1315 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
| 1318 | 1316 | } |
@@ -1320,26 +1318,26 @@ discard block |
||
| 1320 | 1318 | if (Vfs::$is_root) |
| 1321 | 1319 | { |
| 1322 | 1320 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
| 1323 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
| 1321 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
| 1324 | 1322 | // Need a more complex submit because button type is buttononly, which doesn't submit |
| 1325 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
| 1323 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
| 1326 | 1324 | |
| 1327 | 1325 | } |
| 1328 | 1326 | elseif ($button == 'sudo') |
| 1329 | 1327 | { |
| 1330 | 1328 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
| 1331 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
| 1332 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
| 1329 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
| 1330 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
| 1333 | 1331 | } |
| 1334 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
| 1332 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
| 1335 | 1333 | { |
| 1336 | 1334 | // add to existing tabs in template |
| 1337 | 1335 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
| 1338 | 1336 | |
| 1339 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
| 1337 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
| 1340 | 1338 | if (true) $tabs = array(); |
| 1341 | 1339 | |
| 1342 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 1340 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 1343 | 1341 | { |
| 1344 | 1342 | $tabs[] = array( |
| 1345 | 1343 | 'label' => $extra_tab['label'], |
@@ -1362,7 +1360,7 @@ discard block |
||
| 1362 | 1360 | Framework::window_focus(); |
| 1363 | 1361 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
| 1364 | 1362 | |
| 1365 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
| 1363 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
| 1366 | 1364 | } |
| 1367 | 1365 | |
| 1368 | 1366 | /** |
@@ -1373,7 +1371,7 @@ discard block |
||
| 1373 | 1371 | * @param string $dir=null current directory |
| 1374 | 1372 | * @see static::action() |
| 1375 | 1373 | */ |
| 1376 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
| 1374 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
| 1377 | 1375 | { |
| 1378 | 1376 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
| 1379 | 1377 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1392,15 +1390,15 @@ discard block |
||
| 1392 | 1390 | |
| 1393 | 1391 | if (!isset($dir)) $dir = array_pop($selected); |
| 1394 | 1392 | |
| 1395 | - switch($action) |
|
| 1393 | + switch ($action) |
|
| 1396 | 1394 | { |
| 1397 | 1395 | case 'upload': |
| 1398 | 1396 | $script_error = 0; |
| 1399 | - foreach($selected as $tmp_name => &$data) |
|
| 1397 | + foreach ($selected as $tmp_name => &$data) |
|
| 1400 | 1398 | { |
| 1401 | 1399 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
| 1402 | 1400 | |
| 1403 | - if(Vfs::deny_script($path)) |
|
| 1401 | + if (Vfs::deny_script($path)) |
|
| 1404 | 1402 | { |
| 1405 | 1403 | if (!isset($script_error)) |
| 1406 | 1404 | { |
@@ -1422,7 +1420,7 @@ discard block |
||
| 1422 | 1420 | { |
| 1423 | 1421 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
| 1424 | 1422 | { |
| 1425 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
| 1423 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
| 1426 | 1424 | } |
| 1427 | 1425 | else |
| 1428 | 1426 | { |
@@ -1457,16 +1455,16 @@ discard block |
||
| 1457 | 1455 | case 'link': |
| 1458 | 1456 | // First upload |
| 1459 | 1457 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
| 1460 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
| 1458 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
| 1461 | 1459 | |
| 1462 | - foreach($arr['uploaded'] as $file) |
|
| 1460 | + foreach ($arr['uploaded'] as $file) |
|
| 1463 | 1461 | { |
| 1464 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
| 1462 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
| 1465 | 1463 | if (Vfs::file_exists($target) && $app_dir) |
| 1466 | 1464 | { |
| 1467 | 1465 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
| 1468 | 1466 | error_log("Symlinking $target to $app_dir"); |
| 1469 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
| 1467 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
| 1470 | 1468 | } |
| 1471 | 1469 | } |
| 1472 | 1470 | // Must return to avoid adding to $response again |
@@ -1488,7 +1486,7 @@ discard block |
||
| 1488 | 1486 | */ |
| 1489 | 1487 | private function perms2mode(array $perms) |
| 1490 | 1488 | { |
| 1491 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
| 1489 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
| 1492 | 1490 | if ($mode['executable']) |
| 1493 | 1491 | { |
| 1494 | 1492 | $mode |= 0111; |