From 2a930e5a6663c6b94d21fe3c81104fe6b016f863 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Sun, 24 Mar 2019 18:45:22 +0100 Subject: [PATCH] Log the ID of the current user when emptying the media recycle bin --- src/Umbraco.Core/Services/IMediaService.cs | 8 ++++++++ src/Umbraco.Core/Services/MediaService.cs | 12 ++++++++++-- src/Umbraco.Web/Editors/MediaController.cs | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Services/IMediaService.cs b/src/Umbraco.Core/Services/IMediaService.cs index f5f136b789..4e3189bf72 100644 --- a/src/Umbraco.Core/Services/IMediaService.cs +++ b/src/Umbraco.Core/Services/IMediaService.cs @@ -289,8 +289,16 @@ namespace Umbraco.Core.Services /// /// Empties the Recycle Bin by deleting all that resides in the bin /// + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("Use EmptyRecycleBin with explicit indication of user ID instead")] void EmptyRecycleBin(); + /// + /// Empties the Recycle Bin by deleting all that resides in the bin + /// + /// Optional Id of the User emptying the Recycle Bin + void EmptyRecycleBin(int userId = 0); + /// /// Deletes all media of specified type. All children of deleted media is moved to Recycle Bin. /// diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index b95a8a258c..873cff2bf5 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -981,7 +981,15 @@ namespace Umbraco.Core.Services /// /// Empties the Recycle Bin by deleting all that resides in the bin /// - public void EmptyRecycleBin() + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("Use EmptyRecycleBin with explicit indication of user ID instead")] + public void EmptyRecycleBin() => EmptyRecycleBin(0); + + /// + /// Empties the Recycle Bin by deleting all that resides in the bin + /// + /// Optional Id of the User emptying the Recycle Bin + public void EmptyRecycleBin(int userId = 0) { using (new WriteLock(Locker)) { @@ -1006,7 +1014,7 @@ namespace Umbraco.Core.Services recycleBinEventArgs.RecycleBinEmptiedSuccessfully = success; uow.Events.Dispatch(EmptiedRecycleBin, this, recycleBinEventArgs); - Audit(uow, AuditType.Delete, "Empty Media Recycle Bin performed by user", 0, Constants.System.RecycleBinMedia); + Audit(uow, AuditType.Delete, "Empty Media Recycle Bin performed by user", userId, Constants.System.RecycleBinMedia); uow.Commit(); } } diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index fe238219d7..1cc561ce9f 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -583,7 +583,7 @@ namespace Umbraco.Web.Editors [HttpPost] public HttpResponseMessage EmptyRecycleBin() { - Services.MediaService.EmptyRecycleBin(); + Services.MediaService.EmptyRecycleBin(Security.CurrentUser.Id); return Request.CreateNotificationSuccessResponse(Services.TextService.Localize("defaultdialogs/recycleBinIsEmpty")); }