mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Started testing work for recycle bin implementation
This commit is contained in:
@ -23,7 +23,12 @@ class AuditLogController extends Controller
|
||||
];
|
||||
|
||||
$query = Activity::query()
|
||||
->with(['entity', 'user'])
|
||||
->with([
|
||||
'entity' => function ($query) {
|
||||
$query->withTrashed();
|
||||
},
|
||||
'user'
|
||||
])
|
||||
->orderBy($listDetails['sort'], $listDetails['order']);
|
||||
|
||||
if ($listDetails['event']) {
|
||||
|
@ -181,14 +181,13 @@ class BookController extends Controller
|
||||
/**
|
||||
* Remove the specified book from the system.
|
||||
* @throws Throwable
|
||||
* @throws NotifyException
|
||||
*/
|
||||
public function destroy(string $bookSlug)
|
||||
{
|
||||
$book = $this->bookRepo->getBySlug($bookSlug);
|
||||
$this->checkOwnablePermission('book-delete', $book);
|
||||
|
||||
Activity::addMessage('book_delete', $book->name);
|
||||
Activity::add($book, 'book_delete', $book->id);
|
||||
$this->bookRepo->destroy($book);
|
||||
|
||||
return redirect('/books');
|
||||
|
@ -182,7 +182,7 @@ class BookshelfController extends Controller
|
||||
$shelf = $this->bookshelfRepo->getBySlug($slug);
|
||||
$this->checkOwnablePermission('bookshelf-delete', $shelf);
|
||||
|
||||
Activity::addMessage('bookshelf_delete', $shelf->name);
|
||||
Activity::add($shelf, 'bookshelf_delete');
|
||||
$this->bookshelfRepo->destroy($shelf);
|
||||
|
||||
return redirect('/shelves');
|
||||
|
@ -128,7 +128,7 @@ class ChapterController extends Controller
|
||||
$chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
|
||||
$this->checkOwnablePermission('chapter-delete', $chapter);
|
||||
|
||||
Activity::addMessage('chapter_delete', $chapter->name, $chapter->book->id);
|
||||
Activity::add($chapter, 'chapter_delete', $chapter->book->id);
|
||||
$this->chapterRepo->destroy($chapter);
|
||||
|
||||
return redirect($chapter->book->getUrl());
|
||||
|
@ -308,9 +308,8 @@ class PageController extends Controller
|
||||
$book = $page->book;
|
||||
$parent = $page->chapter ?? $book;
|
||||
$this->pageRepo->destroy($page);
|
||||
Activity::addMessage('page_delete', $page->name, $book->id);
|
||||
Activity::add($page, 'page_delete', $page->book_id);
|
||||
|
||||
$this->showSuccessNotification(trans('entities.pages_delete_success'));
|
||||
return redirect($parent->getUrl());
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ class RecycleBinController extends Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// TODO - Check this is enforced.
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->checkPermission('settings-manage');
|
||||
$this->checkPermission('restrictions-manage-all');
|
||||
@ -96,7 +95,7 @@ class RecycleBinController extends Controller
|
||||
*/
|
||||
public function empty()
|
||||
{
|
||||
$deleteCount = (new TrashCan())->destroyFromAllDeletions();
|
||||
$deleteCount = (new TrashCan())->empty();
|
||||
|
||||
$this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
|
||||
return redirect($this->recycleBinBaseUrl);
|
||||
|
Reference in New Issue
Block a user