@@ -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 | } |
@@ -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( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ), |
210 | 210 | // DRAG and DROP events |
211 | 211 | 'file_drag' => array( |
212 | - 'dragType' => array('file','link'), |
|
212 | + 'dragType' => array('file', 'link'), |
|
213 | 213 | 'type' => 'drag', |
214 | 214 | 'onExecute' => 'javaScript:app.filemanager.drag' |
215 | 215 | ), |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
251 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
252 | 252 | { |
253 | 253 | $actions['mail']['children']['mail_'.$mode] = array( |
254 | 254 | 'caption' => $data['label'], |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | } |
260 | 260 | } |
261 | 261 | // This would be done automatically, but we're overriding |
262 | - foreach($actions as $action_id => $action) |
|
262 | + foreach ($actions as $action_id => $action) |
|
263 | 263 | { |
264 | - if($action['type'] == 'drop' && $action['caption']) |
|
264 | + if ($action['type'] == 'drop' && $action['caption']) |
|
265 | 265 | { |
266 | 266 | $action['type'] = 'popup'; |
267 | - if($action['acceptedTypes'] == 'file') |
|
267 | + if ($action['acceptedTypes'] == 'file') |
|
268 | 268 | { |
269 | 269 | $action['enabled'] = 'javaScript:app.filemanager.paste_enabled'; |
270 | 270 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | // Anonymous users have limited actions |
276 | - if(self::is_anonymous($GLOBALS['egw_info']['user']['account_id'])) |
|
276 | + if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id'])) |
|
277 | 277 | { |
278 | 278 | self::restrict_anonymous_actions($actions); |
279 | 279 | } |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return string merge application or NULL if no property found |
292 | 292 | */ |
293 | - private static function get_mergeapp($path, $scope='self') |
|
293 | + private static function get_mergeapp($path, $scope = 'self') |
|
294 | 294 | { |
295 | 295 | $app = null; |
296 | - switch($scope) |
|
296 | + switch ($scope) |
|
297 | 297 | { |
298 | 298 | case 'self': |
299 | 299 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | case 'parents': |
303 | 303 | // search for props in parent directories |
304 | 304 | $currentpath = $path; |
305 | - while($dir = Vfs::dirname($currentpath)) |
|
305 | + while ($dir = Vfs::dirname($currentpath)) |
|
306 | 306 | { |
307 | 307 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
308 | - if(!empty($props)) |
|
308 | + if (!empty($props)) |
|
309 | 309 | { |
310 | 310 | // found prop in parent directory |
311 | 311 | return $app = $props[0]['val']; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param array $content |
325 | 325 | * @param string $msg |
326 | 326 | */ |
327 | - function index(array $content=null,$msg=null) |
|
327 | + function index(array $content = null, $msg = null) |
|
328 | 328 | { |
329 | 329 | if (!is_array($content)) |
330 | 330 | { |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | if (!is_array($content['nm'])) |
335 | 335 | { |
336 | 336 | $content['nm'] = array( |
337 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
338 | - 'filter' => '', // current dir only |
|
339 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
340 | - 'no_cat' => True, // I disable the cat-selectbox |
|
341 | - 'lettersearch' => True, // I show a lettersearch |
|
342 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
343 | - 'start' => 0, // IO position in list |
|
344 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
345 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
346 | - '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 |
|
337 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
338 | + 'filter' => '', // current dir only |
|
339 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
340 | + 'no_cat' => True, // I disable the cat-selectbox |
|
341 | + 'lettersearch' => True, // I show a lettersearch |
|
342 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
343 | + 'start' => 0, // IO position in list |
|
344 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
345 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
346 | + '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 |
|
347 | 347 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
348 | 348 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
349 | 349 | 'row_id' => 'path', |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | 'parent_id' => 'dir', |
352 | 352 | 'is_parent' => 'is_dir', |
353 | 353 | 'favorites' => true, |
354 | - 'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
354 | + 'placeholder_actions' => array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
355 | 355 | ); |
356 | 356 | $content['nm']['path'] = static::get_home_dir(); |
357 | 357 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
375 | 375 | { |
376 | - switch($path) |
|
376 | + switch ($path) |
|
377 | 377 | { |
378 | 378 | case '..': |
379 | 379 | $path = Vfs::dirname($content['nm']['path']); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $path = static::get_home_dir(); |
383 | 383 | break; |
384 | 384 | } |
385 | - if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
385 | + if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
386 | 386 | { |
387 | 387 | $content['nm']['path'] = $path; |
388 | 388 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | } |
399 | 399 | $view = static::get_view(); |
400 | 400 | |
401 | - call_user_func($view,$content,$msg); |
|
401 | + call_user_func($view, $content, $msg); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
412 | 412 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
413 | 413 | */ |
414 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
414 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
415 | 415 | { |
416 | 416 | if (!$user) |
417 | 417 | { |
@@ -420,15 +420,15 @@ discard block |
||
420 | 420 | else |
421 | 421 | { |
422 | 422 | // config user & password |
423 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
423 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
424 | 424 | // or vfs root user from setup >> configuration |
425 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
426 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
425 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
426 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
427 | 427 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
428 | 428 | } |
429 | 429 | //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)); |
430 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
431 | - Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
430 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
431 | + Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
432 | 432 | return Vfs::$is_root; |
433 | 433 | } |
434 | 434 | |
@@ -438,18 +438,18 @@ discard block |
||
438 | 438 | * @param array $content |
439 | 439 | * @param string $msg |
440 | 440 | */ |
441 | - function listview(array $content=null,$msg=null) |
|
441 | + function listview(array $content = null, $msg = null) |
|
442 | 442 | { |
443 | 443 | $tpl = new Etemplate('filemanager.index'); |
444 | 444 | |
445 | - if($msg) Framework::message($msg); |
|
445 | + if ($msg) Framework::message($msg); |
|
446 | 446 | |
447 | 447 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
448 | 448 | { |
449 | 449 | if ($content['nm']['action']) |
450 | 450 | { |
451 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
452 | - if($msg) Framework::message($msg); |
|
451 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
452 | + if ($msg) Framework::message($msg); |
|
453 | 453 | |
454 | 454 | // clean up after action |
455 | 455 | unset($content['nm']['selected']); |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
461 | 461 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
462 | 462 | } |
463 | - elseif($content['nm']['rows']['delete']) |
|
463 | + elseif ($content['nm']['rows']['delete']) |
|
464 | 464 | { |
465 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
466 | - if($msg) Framework::message($msg); |
|
465 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
466 | + if ($msg) Framework::message($msg); |
|
467 | 467 | |
468 | 468 | // clean up after action |
469 | 469 | unset($content['nm']['rows']['delete']); |
@@ -475,11 +475,11 @@ discard block |
||
475 | 475 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
476 | 476 | } |
477 | 477 | unset($content['nm']['rows']); |
478 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
478 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | // be tolerant with (in previous versions) not correct urlencoded pathes |
482 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
482 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
483 | 483 | { |
484 | 484 | $content['nm']['path'] = urldecode($content['nm']['path']); |
485 | 485 | } |
@@ -490,22 +490,22 @@ discard block |
||
490 | 490 | list($button) = each($content['button']); |
491 | 491 | unset($content['button']); |
492 | 492 | } |
493 | - switch($button) |
|
493 | + switch ($button) |
|
494 | 494 | { |
495 | 495 | case 'upload': |
496 | 496 | if (!$content['upload']) |
497 | 497 | { |
498 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
498 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
499 | 499 | break; |
500 | 500 | } |
501 | 501 | $upload_success = $upload_failure = array(); |
502 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
502 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
503 | 503 | { |
504 | 504 | // encode chars which special meaning in url/vfs (some like / get removed!) |
505 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
505 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
506 | 506 | if ($upload && |
507 | 507 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
508 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
508 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
509 | 509 | { |
510 | 510 | $upload_success[] = $upload['name']; |
511 | 511 | } |
@@ -517,12 +517,11 @@ discard block |
||
517 | 517 | $content['nm']['msg'] = ''; |
518 | 518 | if ($upload_success) |
519 | 519 | { |
520 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
521 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
520 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
522 | 521 | } |
523 | 522 | if ($upload_failure) |
524 | 523 | { |
525 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
524 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
526 | 525 | } |
527 | 526 | break; |
528 | 527 | } |
@@ -543,16 +542,16 @@ discard block |
||
543 | 542 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
544 | 543 | } |
545 | 544 | // Set view button to match current settings |
546 | - if($content['nm']['view'] == 'tile') |
|
545 | + if ($content['nm']['view'] == 'tile') |
|
547 | 546 | { |
548 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
549 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
547 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
548 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
550 | 549 | } |
551 | 550 | // if initial load is done via GET request (idots template or share.php) |
552 | 551 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
553 | 552 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
554 | 553 | |
555 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
554 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
556 | 555 | } |
557 | 556 | |
558 | 557 | /** |
@@ -588,7 +587,7 @@ discard block |
||
588 | 587 | * @param int &$files=null on return number of files deleted |
589 | 588 | * @return string success or failure message displayed to the user |
590 | 589 | */ |
591 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
590 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
592 | 591 | { |
593 | 592 | if (!count($selected)) |
594 | 593 | { |
@@ -596,20 +595,20 @@ discard block |
||
596 | 595 | } |
597 | 596 | $errs = $dirs = $files = 0; |
598 | 597 | |
599 | - switch($action) |
|
598 | + switch ($action) |
|
600 | 599 | { |
601 | 600 | |
602 | 601 | case 'delete': |
603 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
602 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
604 | 603 | |
605 | 604 | case 'mail': |
606 | 605 | case 'copy': |
607 | - foreach($selected as $path) |
|
606 | + foreach ($selected as $path) |
|
608 | 607 | { |
609 | 608 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
610 | 609 | { |
611 | 610 | // Support for dropping mail in filemanager - Pass mail back to mail app |
612 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
611 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
613 | 612 | { |
614 | 613 | ++$files; |
615 | 614 | } |
@@ -620,8 +619,8 @@ discard block |
||
620 | 619 | } |
621 | 620 | elseif (!Vfs::is_dir($path)) |
622 | 621 | { |
623 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
624 | - if ($path != $to && Vfs::copy($path,$to)) |
|
622 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
623 | + if ($path != $to && Vfs::copy($path, $to)) |
|
625 | 624 | { |
626 | 625 | ++$files; |
627 | 626 | } |
@@ -633,19 +632,19 @@ discard block |
||
633 | 632 | else |
634 | 633 | { |
635 | 634 | $len = strlen(dirname($path)); |
636 | - foreach(Vfs::find($path) as $p) |
|
635 | + foreach (Vfs::find($path) as $p) |
|
637 | 636 | { |
638 | - $to = $dir.substr($p,$len); |
|
637 | + $to = $dir.substr($p, $len); |
|
639 | 638 | if ($to == $p) // cant copy into itself! |
640 | 639 | { |
641 | 640 | ++$errs; |
642 | 641 | continue; |
643 | 642 | } |
644 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
643 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
645 | 644 | { |
646 | 645 | ++$dirs; |
647 | 646 | } |
648 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
647 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
649 | 648 | { |
650 | 649 | ++$files; |
651 | 650 | } |
@@ -658,15 +657,15 @@ discard block |
||
658 | 657 | } |
659 | 658 | if ($errs) |
660 | 659 | { |
661 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
660 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
662 | 661 | } |
663 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
662 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
664 | 663 | |
665 | 664 | case 'move': |
666 | - foreach($selected as $path) |
|
665 | + foreach ($selected as $path) |
|
667 | 666 | { |
668 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
669 | - if ($path != $to && Vfs::rename($path,$to)) |
|
667 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
668 | + if ($path != $to && Vfs::rename($path, $to)) |
|
670 | 669 | { |
671 | 670 | ++$files; |
672 | 671 | } |
@@ -677,17 +676,17 @@ discard block |
||
677 | 676 | } |
678 | 677 | if ($errs) |
679 | 678 | { |
680 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
679 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
681 | 680 | } |
682 | - return lang('%1 files moved.',$files); |
|
681 | + return lang('%1 files moved.', $files); |
|
683 | 682 | |
684 | 683 | case 'symlink': // symlink given files to $dir |
685 | - foreach((array)$selected as $target) |
|
684 | + foreach ((array)$selected as $target) |
|
686 | 685 | { |
687 | 686 | $link = Vfs::concat($dir, Vfs::basename($target)); |
688 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
687 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
689 | 688 | { |
690 | - if(!$ok) |
|
689 | + if (!$ok) |
|
691 | 690 | { |
692 | 691 | $errs++; |
693 | 692 | continue; |
@@ -709,15 +708,14 @@ discard block |
||
709 | 708 | } |
710 | 709 | if (count((array)$selected) == 1) |
711 | 710 | { |
712 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
713 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
711 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
714 | 712 | } |
715 | 713 | $ret = lang('%1 elements linked.', $files); |
716 | 714 | if ($errs) |
717 | 715 | { |
718 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
716 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
719 | 717 | } |
720 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
718 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
721 | 719 | |
722 | 720 | case 'createdir': |
723 | 721 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -733,13 +731,13 @@ discard block |
||
733 | 731 | |
734 | 732 | default: |
735 | 733 | list($action, $settings) = explode('_', $action, 2); |
736 | - switch($action) |
|
734 | + switch ($action) |
|
737 | 735 | { |
738 | 736 | case 'document': |
739 | 737 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
740 | 738 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
741 | 739 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
742 | - if($msg) return $msg; |
|
740 | + if ($msg) return $msg; |
|
743 | 741 | $errs = count($selected); |
744 | 742 | return false; |
745 | 743 | } |
@@ -756,12 +754,12 @@ discard block |
||
756 | 754 | * @param int &$files=null on return number of files deleted |
757 | 755 | * @return string |
758 | 756 | */ |
759 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
757 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
760 | 758 | { |
761 | 759 | $dirs = $files = $errs = 0; |
762 | 760 | // we first delete all selected links (and files) |
763 | 761 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
764 | - foreach($selected as $key => $path) |
|
762 | + foreach ($selected as $key => $path) |
|
765 | 763 | { |
766 | 764 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
767 | 765 | { |
@@ -779,21 +777,21 @@ discard block |
||
779 | 777 | if ($selected) // somethings left to delete |
780 | 778 | { |
781 | 779 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
782 | - foreach((array)$selected as $path) |
|
780 | + foreach ((array)$selected as $path) |
|
783 | 781 | { |
784 | 782 | if (Vfs::isProtectedDir($path)) |
785 | 783 | { |
786 | 784 | $errs++; |
787 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
785 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
788 | 786 | } |
789 | 787 | } |
790 | 788 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
791 | 789 | // - depth=true to get first the files and then the dir containing it |
792 | 790 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
793 | 791 | // - show-deleted=false to not (finally) deleted versioned files |
794 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
792 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
795 | 793 | { |
796 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
794 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
797 | 795 | { |
798 | 796 | ++$dirs; |
799 | 797 | } |
@@ -809,13 +807,13 @@ discard block |
||
809 | 807 | } |
810 | 808 | if ($errs) |
811 | 809 | { |
812 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
810 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
813 | 811 | } |
814 | 812 | if ($dirs) |
815 | 813 | { |
816 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
814 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
817 | 815 | } |
818 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
816 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
819 | 817 | } |
820 | 818 | |
821 | 819 | /** |
@@ -830,37 +828,37 @@ discard block |
||
830 | 828 | if (!$query['csv_export']) |
831 | 829 | { |
832 | 830 | Api\Cache::setSession('filemanager', 'index', |
833 | - array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
|
831 | + array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
834 | 832 | } |
835 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
833 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
836 | 834 | |
837 | 835 | // Change template to match selected view |
838 | - if($query['view']) |
|
836 | + if ($query['view']) |
|
839 | 837 | { |
840 | 838 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
841 | 839 | |
842 | 840 | // Store as preference but only for index, not home |
843 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
841 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
844 | 842 | { |
845 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
843 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
846 | 844 | $GLOBALS['egw']->preferences->save_repository(); |
847 | 845 | } |
848 | 846 | } |
849 | 847 | // be tolerant with (in previous versions) not correct urlencoded pathes |
850 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
848 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
851 | 849 | { |
852 | 850 | $query['path'] = urldecode($query['path']); |
853 | 851 | } |
854 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
852 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
855 | 853 | { |
856 | 854 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
857 | 855 | if ($query['path'] != ($path = static::get_home_dir())) |
858 | 856 | { |
859 | 857 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
860 | 858 | // an appropriate message |
861 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
859 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
862 | 860 | 'path' => $path, |
863 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
861 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
864 | 862 | 'ajax' => 'true' |
865 | 863 | )); |
866 | 864 | } |
@@ -868,35 +866,35 @@ discard block |
||
868 | 866 | return 0; |
869 | 867 | } |
870 | 868 | $rows = $dir_is_writable = array(); |
871 | - if($query['searchletter'] && !empty($query['search'])) |
|
869 | + if ($query['searchletter'] && !empty($query['search'])) |
|
872 | 870 | { |
873 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
871 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
874 | 872 | if ($query['searchletter'] == strtolower($query['search'][0])) |
875 | 873 | { |
876 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
877 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
874 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
875 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
878 | 876 | } |
879 | 877 | } |
880 | 878 | elseif ($query['searchletter']) |
881 | 879 | { |
882 | 880 | $namefilter = '/^'.$query['searchletter'].'/i'; |
883 | 881 | } |
884 | - elseif(!empty($query['search'])) |
|
882 | + elseif (!empty($query['search'])) |
|
885 | 883 | { |
886 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
884 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
887 | 885 | } |
888 | 886 | |
889 | 887 | // Re-map so 'No filters' favorite ('') is depth 1 |
890 | 888 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
891 | 889 | |
892 | 890 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
893 | - if($filter == 5) $maxdepth = 2; |
|
891 | + if ($filter == 5) $maxdepth = 2; |
|
894 | 892 | $n = 0; |
895 | 893 | $vfs_options = array( |
896 | 894 | 'mindepth' => 1, |
897 | 895 | 'maxdepth' => $maxdepth, |
898 | 896 | 'dirsontop' => $filter <= 1, |
899 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
897 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
900 | 898 | 'order' => $query['order'], 'sort' => $query['sort'], |
901 | 899 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
902 | 900 | 'need_mime' => true, |
@@ -904,11 +902,11 @@ discard block |
||
904 | 902 | 'hidden' => $filter == 3, |
905 | 903 | 'follow' => $filter == 5, |
906 | 904 | ); |
907 | - if($query['col_filter']['mime']) |
|
905 | + if ($query['col_filter']['mime']) |
|
908 | 906 | { |
909 | 907 | $vfs_options['mime'] = $query['col_filter']['mime']; |
910 | 908 | } |
911 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
909 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
912 | 910 | { |
913 | 911 | //echo $path; _debug_array($row); |
914 | 912 | |
@@ -927,37 +925,37 @@ discard block |
||
927 | 925 | $row['class'] .= 'isDir '; |
928 | 926 | $row['is_dir'] = 1; |
929 | 927 | } |
930 | - if(!$dir_is_writable[$path]) |
|
928 | + if (!$dir_is_writable[$path]) |
|
931 | 929 | { |
932 | 930 | $row['class'] .= 'noEdit '; |
933 | 931 | } |
934 | 932 | $row['download_url'] = Vfs::download_url($path); |
935 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
933 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
936 | 934 | |
937 | 935 | $rows[++$n] = $row; |
938 | 936 | $path2n[$path] = $n; |
939 | 937 | } |
940 | 938 | // query comments and cf's for the displayed rows |
941 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
939 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
942 | 940 | |
943 | 941 | // Always include comment in tiles |
944 | - if($query['view'] == 'tile') |
|
942 | + if ($query['view'] == 'tile') |
|
945 | 943 | { |
946 | 944 | $cols_to_show[] = 'comment'; |
947 | 945 | } |
948 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
949 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
946 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
947 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
950 | 948 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
951 | 949 | { |
952 | - foreach($path2props as $path => $props) |
|
950 | + foreach ($path2props as $path => $props) |
|
953 | 951 | { |
954 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
955 | - $row =& $rows[$path2n[$path]]; |
|
956 | - if ( !is_array($props) ) continue; |
|
957 | - foreach($props as $prop) |
|
952 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
953 | + $row = & $rows[$path2n[$path]]; |
|
954 | + if (!is_array($props)) continue; |
|
955 | + foreach ($props as $prop) |
|
958 | 956 | { |
959 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
960 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
957 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
958 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
961 | 959 | } |
962 | 960 | } |
963 | 961 | } |
@@ -969,7 +967,7 @@ discard block |
||
969 | 967 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
970 | 968 | { |
971 | 969 | // we need our app.css file |
972 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
970 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
973 | 971 | { |
974 | 972 | $css_file = '/filemanager/templates/default/app.css'; |
975 | 973 | } |
@@ -985,7 +983,7 @@ discard block |
||
985 | 983 | * @param array $content |
986 | 984 | * @param string $msg |
987 | 985 | */ |
988 | - function file(array $content=null,$msg='') |
|
986 | + function file(array $content = null, $msg = '') |
|
989 | 987 | { |
990 | 988 | $tpl = new Etemplate('filemanager.file'); |
991 | 989 | |
@@ -995,9 +993,9 @@ discard block |
||
995 | 993 | { |
996 | 994 | $msg .= $_GET['msg']; |
997 | 995 | } |
998 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
996 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
999 | 997 | // actions enclose pathes containing comma with " |
1000 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
998 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
1001 | 999 | !($stat = Vfs::lstat($path))) |
1002 | 1000 | { |
1003 | 1001 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -1010,10 +1008,10 @@ discard block |
||
1010 | 1008 | $content['path'] = $path; |
1011 | 1009 | $content['hsize'] = Vfs::hsize($stat['size']); |
1012 | 1010 | $content['mime'] = Vfs::mime_content_type($path); |
1013 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
1011 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
1014 | 1012 | if (($props = Vfs::propfind($path))) |
1015 | 1013 | { |
1016 | - foreach($props as $prop) |
|
1014 | + foreach ($props as $prop) |
|
1017 | 1015 | { |
1018 | 1016 | $content[$prop['name']] = $prop['val']; |
1019 | 1017 | } |
@@ -1026,9 +1024,9 @@ discard block |
||
1026 | 1024 | $content['tabs'] = $_GET['tabs']; |
1027 | 1025 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
1028 | 1026 | { |
1029 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
1027 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
1030 | 1028 | $mask = 6; |
1031 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
1029 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
1032 | 1030 | { |
1033 | 1031 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
1034 | 1032 | } |
@@ -1038,19 +1036,19 @@ discard block |
||
1038 | 1036 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
1039 | 1037 | $mask = 7; |
1040 | 1038 | } |
1041 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
1039 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
1042 | 1040 | { |
1043 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
1041 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
1044 | 1042 | } |
1045 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
1043 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
1046 | 1044 | } |
1047 | 1045 | else |
1048 | 1046 | { |
1049 | 1047 | //_debug_array($content); |
1050 | - $path =& $content['path']; |
|
1048 | + $path = & $content['path']; |
|
1051 | 1049 | |
1052 | 1050 | list($button) = @each($content['button']); unset($content['button']); |
1053 | - if(!$button && $content['sudo']) |
|
1051 | + if (!$button && $content['sudo']) |
|
1054 | 1052 | { |
1055 | 1053 | // Button to stop sudo is not in button namespace |
1056 | 1054 | $button = 'sudo'; |
@@ -1059,21 +1057,21 @@ discard block |
||
1059 | 1057 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
1060 | 1058 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
1061 | 1059 | { |
1062 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
1060 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
1063 | 1061 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
1064 | 1062 | lang('Wrong username or password!') : lang('Root access stopped.')); |
1065 | 1063 | unset($content['sudo']); |
1066 | 1064 | $content['is_owner'] = Vfs::has_owner_rights($path); |
1067 | 1065 | } |
1068 | - if (in_array($button,array('save','apply'))) |
|
1066 | + if (in_array($button, array('save', 'apply'))) |
|
1069 | 1067 | { |
1070 | 1068 | $props = array(); |
1071 | 1069 | $perm_changed = $perm_failed = 0; |
1072 | - foreach($content['old'] as $name => $old_value) |
|
1070 | + foreach ($content['old'] as $name => $old_value) |
|
1073 | 1071 | { |
1074 | 1072 | if (isset($content[$name]) && ($old_value != $content[$name] || |
1075 | 1073 | // do not check for modification, if modify_subs is checked! |
1076 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
1074 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
1077 | 1075 | ($name != 'uid' || Vfs::$is_root)) |
1078 | 1076 | { |
1079 | 1077 | if ($name == 'name') |
@@ -1087,23 +1085,23 @@ discard block |
||
1087 | 1085 | $to = Vfs::concat($dir, $content['name']); |
1088 | 1086 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
1089 | 1087 | { |
1090 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
1091 | - lang('To overwrite the existing file store again.',lang($button))); |
|
1088 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
1089 | + lang('To overwrite the existing file store again.', lang($button))); |
|
1092 | 1090 | $content['confirm_overwrite'] = $to; |
1093 | 1091 | if ($button == 'save') $button = 'apply'; |
1094 | 1092 | continue; |
1095 | 1093 | } |
1096 | - if (Vfs::rename($path,$to)) |
|
1094 | + if (Vfs::rename($path, $to)) |
|
1097 | 1095 | { |
1098 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1096 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1099 | 1097 | $content['old']['name'] = $content[$name]; |
1100 | 1098 | $path = $to; |
1101 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1102 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1099 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1100 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1103 | 1101 | } |
1104 | 1102 | else |
1105 | 1103 | { |
1106 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1104 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1107 | 1105 | if (Vfs::deny_script($to)) |
1108 | 1106 | { |
1109 | 1107 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1123,7 +1121,7 @@ discard block |
||
1123 | 1121 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
1124 | 1122 | ), |
1125 | 1123 | ); |
1126 | - if (Vfs::proppatch($path,$mergeprop)) |
|
1124 | + if (Vfs::proppatch($path, $mergeprop)) |
|
1127 | 1125 | { |
1128 | 1126 | $content['old'][$name] = $content[$name]; |
1129 | 1127 | $msg .= lang('Setting for document merge saved.'); |
@@ -1135,22 +1133,22 @@ discard block |
||
1135 | 1133 | } |
1136 | 1134 | else |
1137 | 1135 | { |
1138 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
1139 | - $cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]); |
|
1136 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
1137 | + $cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]); |
|
1140 | 1138 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
1141 | 1139 | if ($content['modify_subs']) |
1142 | 1140 | { |
1143 | 1141 | if ($name == 'perms') |
1144 | 1142 | { |
1145 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
1146 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
1143 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
1144 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
1147 | 1145 | } |
1148 | 1146 | else |
1149 | 1147 | { |
1150 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
1148 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
1151 | 1149 | } |
1152 | 1150 | $ok = $failed = 0; |
1153 | - foreach($changed as &$r) |
|
1151 | + foreach ($changed as &$r) |
|
1154 | 1152 | { |
1155 | 1153 | if ($r) |
1156 | 1154 | { |
@@ -1163,32 +1161,32 @@ discard block |
||
1163 | 1161 | } |
1164 | 1162 | if ($ok && !$failed) |
1165 | 1163 | { |
1166 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1164 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
1167 | 1165 | $content['old'][$name] = $content[$name]; |
1168 | 1166 | } |
1169 | - elseif($failed) |
|
1167 | + elseif ($failed) |
|
1170 | 1168 | { |
1171 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1172 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
1169 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
1170 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
1173 | 1171 | } |
1174 | 1172 | } |
1175 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
1173 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
1176 | 1174 | { |
1177 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
1175 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
1178 | 1176 | $content['old'][$name] = $content[$name]; |
1179 | 1177 | } |
1180 | 1178 | else |
1181 | 1179 | { |
1182 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
1180 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
1183 | 1181 | } |
1184 | 1182 | } |
1185 | 1183 | } |
1186 | 1184 | } |
1187 | 1185 | if ($props) |
1188 | 1186 | { |
1189 | - if (Vfs::proppatch($path,$props)) |
|
1187 | + if (Vfs::proppatch($path, $props)) |
|
1190 | 1188 | { |
1191 | - foreach($props as $prop) |
|
1189 | + foreach ($props as $prop) |
|
1192 | 1190 | { |
1193 | 1191 | $content['old'][$prop['name']] = $prop['val']; |
1194 | 1192 | } |
@@ -1205,8 +1203,8 @@ discard block |
||
1205 | 1203 | if ($content['eacl']['delete']) |
1206 | 1204 | { |
1207 | 1205 | list($ino_owner) = each($content['eacl']['delete']); |
1208 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
1209 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1206 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
1207 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1210 | 1208 | } |
1211 | 1209 | elseif ($button == 'eacl') |
1212 | 1210 | { |
@@ -1216,7 +1214,7 @@ discard block |
||
1216 | 1214 | } |
1217 | 1215 | else |
1218 | 1216 | { |
1219 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
1217 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
1220 | 1218 | lang('ACL added.') : lang('Error adding the ACL!'); |
1221 | 1219 | } |
1222 | 1220 | } |
@@ -1226,7 +1224,7 @@ discard block |
||
1226 | 1224 | } |
1227 | 1225 | if ($content['is_link'] && !Vfs::stat($path)) |
1228 | 1226 | { |
1229 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
1227 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
1230 | 1228 | } |
1231 | 1229 | $content['link'] = Egw::link(Vfs::download_url($path)); |
1232 | 1230 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1235,11 +1233,11 @@ discard block |
||
1235 | 1233 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
1236 | 1234 | // only owner can change group & perms |
1237 | 1235 | if (($readonlys['gid'] = !$content['is_owner'] || |
1238 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs |
|
1236 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs') || // no uid, gid or perms in oldvfs |
|
1239 | 1237 | !Vfs::is_writable($path)) |
1240 | 1238 | { |
1241 | 1239 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1242 | - foreach($content['perms'] as $name => $value) |
|
1240 | + foreach ($content['perms'] as $name => $value) |
|
1243 | 1241 | { |
1244 | 1242 | $readonlys['perms['.$name.']'] = true; |
1245 | 1243 | } |
@@ -1258,37 +1256,37 @@ discard block |
||
1258 | 1256 | } |
1259 | 1257 | elseif (!Vfs::is_writable($path)) |
1260 | 1258 | { |
1261 | - foreach($cfs as $name => $data) |
|
1259 | + foreach ($cfs as $name => $data) |
|
1262 | 1260 | { |
1263 | 1261 | $readonlys['#'.$name] = true; |
1264 | 1262 | } |
1265 | 1263 | } |
1266 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1264 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1267 | 1265 | if ($content['is_dir']) |
1268 | 1266 | { |
1269 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1270 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1267 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1268 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1271 | 1269 | 7 => lang('Display and modification of content'), |
1272 | 1270 | 5 => lang('Display of content'), |
1273 | 1271 | 0 => lang('No access'), |
1274 | 1272 | ); |
1275 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1273 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1276 | 1274 | { |
1277 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1278 | - foreach($content['eacl'] as &$eacl) |
|
1275 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1276 | + foreach ($content['eacl'] as &$eacl) |
|
1279 | 1277 | { |
1280 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
1278 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
1281 | 1279 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
1282 | 1280 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
1283 | 1281 | } |
1284 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
1282 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
1285 | 1283 | $content['eacl']['owner'] = 0; |
1286 | 1284 | $content['eacl']['rights'] = 5; |
1287 | 1285 | } |
1288 | 1286 | } |
1289 | 1287 | else |
1290 | 1288 | { |
1291 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1289 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1292 | 1290 | 6 => lang('Read & write access'), |
1293 | 1291 | 4 => lang('Read access only'), |
1294 | 1292 | 0 => lang('No access'), |
@@ -1298,11 +1296,11 @@ discard block |
||
1298 | 1296 | // mergeapp |
1299 | 1297 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
1300 | 1298 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
1301 | - if(!empty($content['mergeapp'])) |
|
1299 | + if (!empty($content['mergeapp'])) |
|
1302 | 1300 | { |
1303 | 1301 | $content['mergeapp_effective'] = $content['mergeapp']; |
1304 | 1302 | } |
1305 | - elseif(!empty($content['mergeapp_parent'])) |
|
1303 | + elseif (!empty($content['mergeapp_parent'])) |
|
1306 | 1304 | { |
1307 | 1305 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
1308 | 1306 | } |
@@ -1314,7 +1312,7 @@ discard block |
||
1314 | 1312 | $mergeapp_list = Link::app_list('merge'); |
1315 | 1313 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
1316 | 1314 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
1317 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
1315 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
1318 | 1316 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
1319 | 1317 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
1320 | 1318 | // mergeapp other gui options |
@@ -1331,7 +1329,7 @@ discard block |
||
1331 | 1329 | 'comment' => (string)$content['comment'], |
1332 | 1330 | 'mergeapp' => $content['mergeapp'] |
1333 | 1331 | ); |
1334 | - if ($cfs) foreach($cfs as $name => $data) |
|
1332 | + if ($cfs) foreach ($cfs as $name => $data) |
|
1335 | 1333 | { |
1336 | 1334 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1337 | 1335 | } |
@@ -1339,31 +1337,31 @@ discard block |
||
1339 | 1337 | if (Vfs::$is_root) |
1340 | 1338 | { |
1341 | 1339 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
1342 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
1340 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
1343 | 1341 | // Need a more complex submit because button type is buttononly, which doesn't submit |
1344 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
1342 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
1345 | 1343 | |
1346 | 1344 | } |
1347 | 1345 | elseif ($button == 'sudo') |
1348 | 1346 | { |
1349 | 1347 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
1350 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
1351 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
1348 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
1349 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
1352 | 1350 | } |
1353 | 1351 | else if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id'])) |
1354 | 1352 | { |
1355 | 1353 | // Just hide sudo for anonymous users |
1356 | 1354 | $readonlys['sudouser'] = true; |
1357 | 1355 | } |
1358 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
1356 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
1359 | 1357 | { |
1360 | 1358 | // add to existing tabs in template |
1361 | 1359 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1362 | 1360 | |
1363 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
1361 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
1364 | 1362 | if (true) $tabs = array(); |
1365 | 1363 | |
1366 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1364 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1367 | 1365 | { |
1368 | 1366 | $tabs[] = array( |
1369 | 1367 | 'label' => $extra_tab['label'], |
@@ -1386,7 +1384,7 @@ discard block |
||
1386 | 1384 | Framework::window_focus(); |
1387 | 1385 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
1388 | 1386 | |
1389 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
1387 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
1390 | 1388 | } |
1391 | 1389 | |
1392 | 1390 | /** |
@@ -1409,7 +1407,7 @@ discard block |
||
1409 | 1407 | $remove = array( |
1410 | 1408 | 'delete' |
1411 | 1409 | ); |
1412 | - foreach($remove as $key) |
|
1410 | + foreach ($remove as $key) |
|
1413 | 1411 | { |
1414 | 1412 | unset($actions[$key]); |
1415 | 1413 | } |
@@ -1423,7 +1421,7 @@ discard block |
||
1423 | 1421 | * @param string $dir=null current directory |
1424 | 1422 | * @see static::action() |
1425 | 1423 | */ |
1426 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
1424 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
1427 | 1425 | { |
1428 | 1426 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
1429 | 1427 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1442,15 +1440,15 @@ discard block |
||
1442 | 1440 | |
1443 | 1441 | if (!isset($dir)) $dir = array_pop($selected); |
1444 | 1442 | |
1445 | - switch($action) |
|
1443 | + switch ($action) |
|
1446 | 1444 | { |
1447 | 1445 | case 'upload': |
1448 | 1446 | $script_error = 0; |
1449 | - foreach($selected as $tmp_name => &$data) |
|
1447 | + foreach ($selected as $tmp_name => &$data) |
|
1450 | 1448 | { |
1451 | 1449 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
1452 | 1450 | |
1453 | - if(Vfs::deny_script($path)) |
|
1451 | + if (Vfs::deny_script($path)) |
|
1454 | 1452 | { |
1455 | 1453 | if (!isset($script_error)) |
1456 | 1454 | { |
@@ -1472,7 +1470,7 @@ discard block |
||
1472 | 1470 | { |
1473 | 1471 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
1474 | 1472 | { |
1475 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
1473 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
1476 | 1474 | } |
1477 | 1475 | else |
1478 | 1476 | { |
@@ -1504,7 +1502,7 @@ discard block |
||
1504 | 1502 | break; |
1505 | 1503 | |
1506 | 1504 | case 'sharelink': |
1507 | - $share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() ); |
|
1505 | + $share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array()); |
|
1508 | 1506 | $arr["share_link"] = $link = Vfs\Sharing::share2link($share); |
1509 | 1507 | $arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet'); |
1510 | 1508 | break; |
@@ -1513,16 +1511,16 @@ discard block |
||
1513 | 1511 | case 'link': |
1514 | 1512 | // First upload |
1515 | 1513 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
1516 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
1514 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
1517 | 1515 | |
1518 | - foreach($arr['uploaded'] as $file) |
|
1516 | + foreach ($arr['uploaded'] as $file) |
|
1519 | 1517 | { |
1520 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
1518 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
1521 | 1519 | if (Vfs::file_exists($target) && $app_dir) |
1522 | 1520 | { |
1523 | 1521 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
1524 | 1522 | error_log("Symlinking $target to $app_dir"); |
1525 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
1523 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
1526 | 1524 | } |
1527 | 1525 | } |
1528 | 1526 | // Must return to avoid adding to $response again |
@@ -1544,7 +1542,7 @@ discard block |
||
1544 | 1542 | */ |
1545 | 1543 | private function perms2mode(array $perms) |
1546 | 1544 | { |
1547 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
1545 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
1548 | 1546 | if ($mode['executable']) |
1549 | 1547 | { |
1550 | 1548 | $mode |= 0111; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // of the request URI ourselves |
118 | 118 | // if request URI contains a full url, remove schema and domain |
119 | 119 | $matches = null; |
120 | - if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches)) |
|
120 | + if (preg_match('|^https?://[^/]+(/.*)$|', $path_info = $_SERVER['REQUEST_URI'], $matches)) |
|
121 | 121 | { |
122 | 122 | $path_info = $matches[1]; |
123 | 123 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param boolean $keep_session =null null: create a new session, true: try mounting it into existing (already verified) session |
156 | 156 | * @return string with sessionid, does NOT return if no session created |
157 | 157 | */ |
158 | - public static function create_session($keep_session=null) |
|
158 | + public static function create_session($keep_session = null) |
|
159 | 159 | { |
160 | 160 | self::$db = $GLOBALS['egw']->db; |
161 | 161 | |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | // need to reset fs_tab, as resolve_url does NOT work with just share mounted |
209 | 209 | if (count($GLOBALS['egw_info']['server']['vfs_fstab']) <= 1) |
210 | 210 | { |
211 | - unset($GLOBALS['egw_info']['server']['vfs_fstab']); // triggers reset of fstab in mount() |
|
211 | + unset($GLOBALS['egw_info']['server']['vfs_fstab']); // triggers reset of fstab in mount() |
|
212 | 212 | $GLOBALS['egw_info']['server']['vfs_fstab'] = Vfs::mount(); |
213 | 213 | Vfs::clearstatcache(); |
214 | 214 | } |
215 | - $share['resolve_url'] = Vfs::resolve_url($share['share_path'], true, true, true, true); // true = fix evtl. contained url parameter |
|
215 | + $share['resolve_url'] = Vfs::resolve_url($share['share_path'], true, true, true, true); // true = fix evtl. contained url parameter |
|
216 | 216 | // if share not writable append ro=1 to mount url to make it readonly |
217 | 217 | if (!self::$db->from_bool($share['share_writable'])) |
218 | 218 | { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | // update accessed timestamp |
259 | 259 | self::$db->update(self::TABLE, array( |
260 | - 'share_last_accessed' => $share['share_last_accessed']=time(), |
|
260 | + 'share_last_accessed' => $share['share_last_accessed'] = time(), |
|
261 | 261 | ), array( |
262 | 262 | 'share_id' => $share['share_id'], |
263 | 263 | ), __LINE__, __FILE__); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | if ($keep_session || $sessionid) |
300 | 300 | { |
301 | 301 | $_SESSION[Api\Session::EGW_INFO_CACHE] = $GLOBALS['egw_info']; |
302 | - unset($_SESSION[Api\Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request |
|
302 | + unset($_SESSION[Api\Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request |
|
303 | 303 | |
304 | 304 | $_SESSION[Api\Session::EGW_OBJECT_CACHE] = serialize($GLOBALS['egw']); |
305 | 305 | } |
@@ -368,8 +368,7 @@ discard block |
||
368 | 368 | // generate random token (using oppenssl if available otherwise mt_rand based Api\Auth::randomstring) |
369 | 369 | do { |
370 | 370 | $token = function_exists('openssl_random_pseudo_bytes') ? |
371 | - base64_encode(openssl_random_pseudo_bytes(3*self::TOKEN_LENGTH/4)) : |
|
372 | - Api\Auth::randomstring(self::TOKEN_LENGTH); |
|
371 | + base64_encode(openssl_random_pseudo_bytes(3 * self::TOKEN_LENGTH / 4)) : Api\Auth::randomstring(self::TOKEN_LENGTH); |
|
373 | 372 | // base64 can contain chars not allowed in our vfs-urls eg. / or # |
374 | 373 | } while ($token != Vfs::encodePathComponent($token)); |
375 | 374 | |
@@ -389,13 +388,13 @@ discard block |
||
389 | 388 | * @throw Api\Exception\AssertionFailed if user temp. directory does not exist and can not be created |
390 | 389 | * @return array with share data, eg. value for key 'share_token' |
391 | 390 | */ |
392 | - public static function create($path, $mode, $name, $recipients, $extra=array()) |
|
391 | + public static function create($path, $mode, $name, $recipients, $extra = array()) |
|
393 | 392 | { |
394 | 393 | if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db; |
395 | 394 | |
396 | 395 | if (empty($name)) $name = $path; |
397 | 396 | |
398 | - $path2tmp =& Api\Cache::getSession(__CLASS__, 'path2tmp'); |
|
397 | + $path2tmp = & Api\Cache::getSession(__CLASS__, 'path2tmp'); |
|
399 | 398 | |
400 | 399 | // allow filesystem path only for temp_dir |
401 | 400 | $temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'; |
@@ -406,7 +405,7 @@ discard block |
||
406 | 405 | } |
407 | 406 | else |
408 | 407 | { |
409 | - if(parse_url($path, PHP_URL_SCHEME) !== 'vfs') |
|
408 | + if (parse_url($path, PHP_URL_SCHEME) !== 'vfs') |
|
410 | 409 | { |
411 | 410 | $path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path; |
412 | 411 | } |
@@ -420,7 +419,7 @@ discard block |
||
420 | 419 | } |
421 | 420 | // check if file has been shared before, with identical attributes |
422 | 421 | if (($mode != self::LINK || isset($path2tmp[$path])) && |
423 | - ($share = self::$db->select(self::TABLE, '*', $extra+array( |
|
422 | + ($share = self::$db->select(self::TABLE, '*', $extra + array( |
|
424 | 423 | 'share_path' => $mode == 'link' ? $path2tmp[$path] : $vfs_path, |
425 | 424 | 'share_owner' => $GLOBALS['egw_info']['user']['account_id'], |
426 | 425 | 'share_expires' => null, |
@@ -431,7 +430,7 @@ discard block |
||
431 | 430 | // if yes, just add additional recipients |
432 | 431 | $share['share_with'] = $share['share_with'] ? explode(',', $share['share_with']) : array(); |
433 | 432 | $need_save = false; |
434 | - foreach((array)$recipients as $recipient) |
|
433 | + foreach ((array)$recipients as $recipient) |
|
435 | 434 | { |
436 | 435 | if (!in_array($recipient, $share['share_with'])) |
437 | 436 | { |
@@ -461,9 +460,9 @@ discard block |
||
461 | 460 | } |
462 | 461 | $n = 0; |
463 | 462 | do { |
464 | - $tmp_file = Vfs::concat($user_tmp, ($n?$n.'.':'').Vfs::basename($name)); |
|
463 | + $tmp_file = Vfs::concat($user_tmp, ($n ? $n.'.' : '').Vfs::basename($name)); |
|
465 | 464 | } |
466 | - while(!(is_dir($path) && Vfs::mkdir($tmp_file, null, STREAM_MKDIR_RECURSIVE) || |
|
465 | + while (!(is_dir($path) && Vfs::mkdir($tmp_file, null, STREAM_MKDIR_RECURSIVE) || |
|
467 | 466 | !is_dir($path) && (!Vfs::file_exists($tmp_file) && ($fp = Vfs::fopen($tmp_file, 'x')) || |
468 | 467 | // do not copy identical files again to users tmp dir, just re-use them |
469 | 468 | Vfs::file_exists($tmp_file) && Vfs::compare(Vfs::PREFIX.$tmp_file, $path))) && $n++ < 100); |
@@ -488,12 +487,12 @@ discard block |
||
488 | 487 | $async = new Api\Asyncservice(); |
489 | 488 | if (!$async->read('egw_sharing-tmp-cleanup')) |
490 | 489 | { |
491 | - $async->set_timer(array('day' => 28),'egw_sharing-tmp_cleanup','EGroupware\\Api\\Vfs\\Sharing::tmp_cleanup',null); |
|
490 | + $async->set_timer(array('day' => 28), 'egw_sharing-tmp_cleanup', 'EGroupware\\Api\\Vfs\\Sharing::tmp_cleanup', null); |
|
492 | 491 | } |
493 | 492 | } |
494 | 493 | |
495 | 494 | $i = 0; |
496 | - while(true) // self::token() can return an existing value |
|
495 | + while (true) // self::token() can return an existing value |
|
497 | 496 | { |
498 | 497 | try { |
499 | 498 | self::$db->insert(self::TABLE, $share = array( |
@@ -502,12 +501,12 @@ discard block |
||
502 | 501 | 'share_owner' => $GLOBALS['egw_info']['user']['account_id'], |
503 | 502 | 'share_with' => implode(',', (array)$recipients), |
504 | 503 | 'share_created' => time(), |
505 | - )+$extra, false, __LINE__, __FILE__); |
|
504 | + ) + $extra, false, __LINE__, __FILE__); |
|
506 | 505 | |
507 | 506 | $share['share_id'] = self::$db->get_last_insert_id(self::TABLE, 'share_id'); |
508 | 507 | break; |
509 | 508 | } |
510 | - catch(Api\Db\Exception $e) { |
|
509 | + catch (Api\Db\Exception $e) { |
|
511 | 510 | if ($i++ > 3) throw $e; |
512 | 511 | unset($e); |
513 | 512 | } |
@@ -550,8 +549,8 @@ discard block |
||
550 | 549 | |
551 | 550 | // get all temp. files, to be able to delete them |
552 | 551 | $tmp_paths = array(); |
553 | - foreach(self::$db->select(self::TABLE, 'share_path', array( |
|
554 | - "share_path LIKE '/home/%/.tmp/%'")+$keys, __LINE__, __FILE__, false) as $row) |
|
552 | + foreach (self::$db->select(self::TABLE, 'share_path', array( |
|
553 | + "share_path LIKE '/home/%/.tmp/%'") + $keys, __LINE__, __FILE__, false) as $row) |
|
555 | 554 | { |
556 | 555 | $tmp_paths[] = $row['share_path']; |
557 | 556 | } |
@@ -563,7 +562,7 @@ discard block |
||
563 | 562 | // check if temp. files are used elsewhere |
564 | 563 | if ($tmp_paths) |
565 | 564 | { |
566 | - foreach(self::$db->select(self::TABLE, 'share_path,COUNT(*) AS cnt', array( |
|
565 | + foreach (self::$db->select(self::TABLE, 'share_path,COUNT(*) AS cnt', array( |
|
567 | 566 | 'share_path' => $tmp_paths, |
568 | 567 | ), __LINE__, __FILE__, false, 'GROUP BY share_path') as $row) |
569 | 568 | { |
@@ -573,7 +572,7 @@ discard block |
||
573 | 572 | } |
574 | 573 | } |
575 | 574 | // if not delete them |
576 | - foreach($tmp_paths as $path) |
|
575 | + foreach ($tmp_paths as $path) |
|
577 | 576 | { |
578 | 577 | Vfs::remove($path); |
579 | 578 | } |
@@ -607,11 +606,11 @@ discard block |
||
607 | 606 | // remove expired tmp-files unconditionally |
608 | 607 | $having = 'HAVING MAX(share_expires) < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '. |
609 | 608 | // remove without expiration date, when created over 100 days ago AND |
610 | - 'MAX(share_expires) IS NULL AND MAX(share_created) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)). ' AND '. |
|
609 | + 'MAX(share_expires) IS NULL AND MAX(share_created) < '.self::$db->quote(self::$db->to_timestamp(time() - self::TMP_KEEP)).' AND '. |
|
611 | 610 | // (last accessed over 100 days ago OR never) |
612 | - '(MAX(share_last_accessed) IS NULL OR MAX(share_last_accessed) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)).')'; |
|
611 | + '(MAX(share_last_accessed) IS NULL OR MAX(share_last_accessed) < '.self::$db->quote(self::$db->to_timestamp(time() - self::TMP_KEEP)).')'; |
|
613 | 612 | |
614 | - foreach(self::$db->select(self::TABLE, $cols, array( |
|
613 | + foreach (self::$db->select(self::TABLE, $cols, array( |
|
615 | 614 | "share_path LIKE '/home/%/.tmp/%'", |
616 | 615 | ), __LINE__, __FILE__, false, 'GROUP BY share_path '.$having) as $row) |
617 | 616 | { |
@@ -624,7 +623,7 @@ discard block |
||
624 | 623 | else |
625 | 624 | { |
626 | 625 | $share_ids = array(); |
627 | - foreach(self::$db->selec(self::TABLE, 'share_id', array( |
|
626 | + foreach (self::$db->selec(self::TABLE, 'share_id', array( |
|
628 | 627 | 'share_path' => $row['share_path'], |
629 | 628 | ), __LINE__, __FILE__) as $id) |
630 | 629 | { |
@@ -690,11 +689,11 @@ discard block |
||
690 | 689 | { |
691 | 690 | $actions = parent::get_actions(); |
692 | 691 | $group = 1; |
693 | - if(Vfs::is_writable($GLOBALS['egw']->sharing->get_root())) |
|
692 | + if (Vfs::is_writable($GLOBALS['egw']->sharing->get_root())) |
|
694 | 693 | { |
695 | 694 | return $actions; |
696 | 695 | } |
697 | - $actions+= array( |
|
696 | + $actions += array( |
|
698 | 697 | 'egw_copy' => array( |
699 | 698 | 'enabled' => false, |
700 | 699 | 'group' => $group + 0.5, |