From: Vincent Vanwaelscappel Date: Thu, 9 Feb 2023 08:53:08 +0000 (+0100) Subject: wip #5718 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=52aec8d989bd8c962948518aa3c2879d2588de8d;p=fluidbook-toolbox.git wip #5718 @1.5 --- diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index a90d3d0e2..8bea06a33 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -11,6 +11,7 @@ services: - '/home/extranet/share:/application/share' - '/home/toolbox/www:/application' - '/home/toolbox/www/storage/app/public/:/application/public/storage/' + - '/data/extranet/ftp/:/application/ftp/' - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/' - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/' - '/home/extranet:/home/extranet' @@ -71,6 +72,7 @@ services: - '/home/extranet/share:/application/share' - '/home/toolbox/www:/application' - '/home/toolbox/www/storage/app/public/:/application/public/storage/' + - '/data/extranet/ftp/:/application/ftp/' - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/' - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/' - '/home/extranet:/home/extranet' diff --git a/app/Http/Controllers/Admin/FilesController.php b/app/Http/Controllers/Admin/FilesController.php new file mode 100644 index 000000000..683f2df9c --- /dev/null +++ b/app/Http/Controllers/Admin/FilesController.php @@ -0,0 +1,102 @@ + $this->getFiles($id), 'id' => $id]); + } + + protected function getFiles($id = 'me') + { + if ($id === 'me' || !can('files:admin')) { + return $this->_getFiles(backpack_user()->id); + } + return $this->_getFiles($id); + } + + protected function _getFiles($id) + { + /** @var User $user */ + $user = User::withoutGlobalScopes()->find($id); + if (null === $user) { + abort(404); + } + $users = $user->getManagedUsers(); + $files = []; + foreach ($users as $user) { + $this->_listFilesOfUser($user, $files); + } + usort($files, function ($a, $b) { + return -($a['mtime'] - $b['mtime']); + }); + return $files; + } + + protected function _listFilesOfUser($id, &$files) + { + $uFiles = cache()->remember('files_list_user_' . $id, 86400, function () use ($id) { + return $this->___listFilesOfUser($id); + }); + + foreach ($uFiles as $path => $uFile) { + if (isset($files[$path])) { + continue; + } + $files[$path] = $uFile; + } + } + + protected function ___listFilesOfUser($id) + { + + $path = '/application/ftp/' . $id; + if (!file_exists($path) || !is_dir($path)) { + return []; + } + $res = []; + $userFiles = Files::getRecursiveDirectoryIterator($path); + foreach ($userFiles as $file) { + /** @var $file \SplFileInfo */ + if ($file->isDir()) { + continue; + } + + $pathname = $file->getPathname(); + if (isset($files[$pathname])) { + continue; + } + + if (preg_match('|\.in\/(\d)+\/|', $pathname, $matches)) { + $from = $matches[1]; + $to = $id; + } else { + $from = $id; + $to = false; + } + + $res[$pathname] = [ + 'path' => $pathname, + 'name' => $file->getFilename(), + 'ext' => mb_strtolower($file->getExtension()), + 'mtime' => $file->getMTime(), + 'date' => date('Y/m/d', $file->getMTime()), + 'size' => Files::humanReadableSize($file->getSize()), + 'from' => $from, + 'to' => $to, + ]; + } + + return $res; + } +} diff --git a/resources/views/files/files.blade.php b/resources/views/files/files.blade.php new file mode 100644 index 000000000..d87afcc29 --- /dev/null +++ b/resources/views/files/files.blade.php @@ -0,0 +1,2 @@ +{{$id}} +{!! print_r($files,true)!!} diff --git a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php index c394a11b5..c77642250 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -32,9 +32,11 @@ class='nav-icon la la-dashboard'>{{ trans('backpack::base.dashboard') }} +@can('files:read') +@endcan @canany(['quiz:read','quiztranslation:read','elearning_media:read'])