- gate implementation

- protected shared view fix
This commit is contained in:
Čarodej
2021-09-24 10:52:19 +02:00
parent d40108f6a9
commit 19cc01131b
84 changed files with 876 additions and 406 deletions

View File

@@ -26,7 +26,7 @@ class BrowseFolderController
->get();
$files = File::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
->where('folder_id', $root_id)
->where('parent_id', $root_id)
->where('user_id', Auth::id())
->sortable()
->get();

View File

@@ -15,7 +15,7 @@ class BrowseSharedItemsController
$user_id = Auth::id();
// Get shared folders and files
$folder_ids = Share::where('user_id', $user_id)
$parent_ids = Share::where('user_id', $user_id)
->where('type', 'folder')
->pluck('item_id');
@@ -26,7 +26,7 @@ class BrowseSharedItemsController
// Get folders and files
$folders = Folder::with(['parent', 'shared:token,id,item_id,permission,is_protected,expire_in'])
->where('user_id', $user_id)
->whereIn('id', $folder_ids)
->whereIn('id', $parent_ids)
->sortable()
->get();

View File

@@ -25,7 +25,7 @@ class BrowseTrashContentController
$files = File::onlyTrashed()
->with('parent')
->where('folder_id', $root_id)
->where('parent_id', $root_id)
->sortable()
->get();
@@ -55,8 +55,8 @@ class BrowseTrashContentController
->with(['parent'])
->where('user_id', $user_id)
->where(function ($query) use ($folders_trashed) {
$query->whereNull('folder_id');
$query->orWhereNotIn('folder_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'id'))));
$query->whereNull('parent_id');
$query->orWhereNotIn('parent_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'id'))));
})
->sortable()
->get();

View File

@@ -39,7 +39,7 @@ class VisitorBrowseFolderController
->get();
$files = File::where('user_id', $shared->user_id)
->where('folder_id', $id)
->where('parent_id', $id)
->sortable()
->get();

View File

@@ -47,21 +47,21 @@ class VisitorSearchFilesAndFoldersController extends Controller
->get();
// Get accessible folders
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
$accessible_parent_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
// Filter files
$files = $searched_files->filter(function ($file) use ($accessible_folder_ids, $shared) {
$files = $searched_files->filter(function ($file) use ($accessible_parent_ids, $shared) {
// Set public urls
$file->setPublicUrl($shared->token);
// check if item is in accessible folders
return in_array($file->folder_id, $accessible_folder_ids);
return in_array($file->parent_id, $accessible_parent_ids);
});
// Filter folders
$folders = $searched_folders->filter(function ($folder) use ($accessible_folder_ids) {
$folders = $searched_folders->filter(function ($folder) use ($accessible_parent_ids) {
// check if item is in accessible folders
return in_array($folder->id, $accessible_folder_ids);
return in_array($folder->id, $accessible_parent_ids);
});
// Collect folders and files to single array