]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/RecycleBinController.php
Added front-end toggle and testing of inline attachments
[bookstack] / app / Http / Controllers / RecycleBinController.php
index 64459da23d2307c88988a7964bbd764164cb0b4b..a644a2889ca28f1b0b2d648798050a27963696ae 100644 (file)
@@ -1,7 +1,8 @@
 <?php namespace BookStack\Http\Controllers;
 
-use BookStack\Entities\Deletion;
-use BookStack\Entities\Managers\TrashCan;
+use BookStack\Actions\ActivityType;
+use BookStack\Entities\Models\Deletion;
+use BookStack\Entities\Tools\TrashCan;
 
 class RecycleBinController extends Controller
 {
@@ -14,13 +15,11 @@ 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');
             return $next($request);
         });
-        parent::__construct();
     }
 
 
@@ -31,6 +30,7 @@ class RecycleBinController extends Controller
     {
         $deletions = Deletion::query()->with(['deletable', 'deleter'])->paginate(10);
 
+        $this->setPageTitle(trans('settings.recycle_bin'));
         return view('settings.recycle-bin.index', [
             'deletions' => $deletions,
         ]);
@@ -57,6 +57,7 @@ class RecycleBinController extends Controller
     {
         /** @var Deletion $deletion */
         $deletion = Deletion::query()->findOrFail($id);
+        $this->logActivity(ActivityType::RECYCLE_BIN_RESTORE, $deletion);
         $restoreCount = (new TrashCan())->restoreFromDeletion($deletion);
 
         $this->showSuccessNotification(trans('settings.recycle_bin_restore_notification', ['count' => $restoreCount]));
@@ -84,6 +85,7 @@ class RecycleBinController extends Controller
     {
         /** @var Deletion $deletion */
         $deletion = Deletion::query()->findOrFail($id);
+        $this->logActivity(ActivityType::RECYCLE_BIN_DESTROY, $deletion);
         $deleteCount = (new TrashCan())->destroyFromDeletion($deletion);
 
         $this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
@@ -96,8 +98,9 @@ class RecycleBinController extends Controller
      */
     public function empty()
     {
-        $deleteCount = (new TrashCan())->destroyFromAllDeletions();
+        $deleteCount = (new TrashCan())->empty();
 
+        $this->logActivity(ActivityType::RECYCLE_BIN_EMPTY);
         $this->showSuccessNotification(trans('settings.recycle_bin_destroy_notification', ['count' => $deleteCount]));
         return redirect($this->recycleBinBaseUrl);
     }