diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs
index 784d04864e..48e577a8f0 100644
--- a/src/Umbraco.Core/Services/IContentService.cs
+++ b/src/Umbraco.Core/Services/IContentService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
@@ -315,8 +316,16 @@ namespace Umbraco.Core.Services
///
/// Empties the recycle bin.
///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Obsolete("Use EmptyRecycleBin with explicit indication of user ID instead")]
OperationResult EmptyRecycleBin();
+ ///
+ /// Empties the Recycle Bin by deleting all that resides in the bin
+ ///
+ /// Optional Id of the User emptying the Recycle Bin
+ OperationResult EmptyRecycleBin(int userId = Constants.Security.SuperUserId);
+
///
/// Sorts documents.
///
diff --git a/src/Umbraco.Core/Services/IMediaService.cs b/src/Umbraco.Core/Services/IMediaService.cs
index 78da440bc6..3fecb20035 100644
--- a/src/Umbraco.Core/Services/IMediaService.cs
+++ b/src/Umbraco.Core/Services/IMediaService.cs
@@ -162,8 +162,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")]
OperationResult EmptyRecycleBin();
+ ///
+ /// Empties the Recycle Bin by deleting all that resides in the bin
+ ///
+ /// Optional Id of the User emptying the Recycle Bin
+ OperationResult EmptyRecycleBin(int userId = Constants.Security.SuperUserId);
+
///
/// Deletes all media of specified type. All children of deleted media is moved to Recycle Bin.
///
diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs
index a4def1d209..0d35915e72 100644
--- a/src/Umbraco.Core/Services/Implement/ContentService.cs
+++ b/src/Umbraco.Core/Services/Implement/ContentService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Globalization;
using System.Linq;
using Umbraco.Core.Events;
@@ -1939,7 +1940,14 @@ namespace Umbraco.Core.Services.Implement
///
/// Empties the Recycle Bin by deleting all that resides in the bin
///
- public OperationResult EmptyRecycleBin()
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Obsolete("Use EmptyRecycleBin with explicit indication of user ID instead")]
+ public OperationResult EmptyRecycleBin() => EmptyRecycleBin(Constants.Security.SuperUserId);
+
+ ///
+ /// Empties the Recycle Bin by deleting all that resides in the bin
+ ///
+ public OperationResult EmptyRecycleBin(int userId = Constants.Security.SuperUserId)
{
var nodeObjectType = Constants.ObjectTypes.Document;
var deleted = new List();
@@ -1974,7 +1982,7 @@ namespace Umbraco.Core.Services.Implement
recycleBinEventArgs.RecycleBinEmptiedSuccessfully = true; // oh my?!
scope.Events.Dispatch(EmptiedRecycleBin, this, recycleBinEventArgs);
scope.Events.Dispatch(TreeChanged, this, deleted.Select(x => new TreeChange(x, TreeChangeTypes.Remove)).ToEventArgs());
- Audit(AuditType.Delete, 0, Constants.System.RecycleBinContent, "Recycle bin emptied");
+ Audit(AuditType.Delete, userId, Constants.System.RecycleBinContent, "Recycle bin emptied");
scope.Complete();
}
diff --git a/src/Umbraco.Core/Services/Implement/MediaService.cs b/src/Umbraco.Core/Services/Implement/MediaService.cs
index fa72896239..343fb7e2c6 100644
--- a/src/Umbraco.Core/Services/Implement/MediaService.cs
+++ b/src/Umbraco.Core/Services/Implement/MediaService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -1024,7 +1025,15 @@ namespace Umbraco.Core.Services.Implement
///
/// Empties the Recycle Bin by deleting all that resides in the bin
///
- public OperationResult EmptyRecycleBin()
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Obsolete("Use EmptyRecycleBin with explicit indication of user ID instead")]
+ public OperationResult EmptyRecycleBin() => EmptyRecycleBin(Constants.Security.SuperUserId);
+
+ ///
+ /// Empties the Recycle Bin by deleting all that resides in the bin
+ ///
+ /// Optional Id of the User emptying the Recycle Bin
+ public OperationResult EmptyRecycleBin(int userId = Constants.Security.SuperUserId)
{
var nodeObjectType = Constants.ObjectTypes.Media;
var deleted = new List();
@@ -1063,7 +1072,7 @@ namespace Umbraco.Core.Services.Implement
args.CanCancel = false;
scope.Events.Dispatch(EmptiedRecycleBin, this, args);
scope.Events.Dispatch(TreeChanged, this, deleted.Select(x => new TreeChange(x, TreeChangeTypes.Remove)).ToEventArgs());
- Audit(AuditType.Delete, 0, Constants.System.RecycleBinMedia, "Empty Media recycle bin");
+ Audit(AuditType.Delete, userId, Constants.System.RecycleBinMedia, "Empty Media recycle bin");
scope.Complete();
}
diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs
index 4b23e46a6c..de65689353 100644
--- a/src/Umbraco.Web/Editors/ContentController.cs
+++ b/src/Umbraco.Web/Editors/ContentController.cs
@@ -1483,7 +1483,7 @@ namespace Umbraco.Web.Editors
[EnsureUserPermissionForContent(Constants.System.RecycleBinContent, ActionDelete.ActionLetter)]
public HttpResponseMessage EmptyRecycleBin()
{
- Services.ContentService.EmptyRecycleBin();
+ Services.ContentService.EmptyRecycleBin(Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
return Request.CreateNotificationSuccessResponse(Services.TextService.Localize("defaultdialogs/recycleBinIsEmpty"));
}
diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs
index 6710cf59f6..1097646830 100644
--- a/src/Umbraco.Web/Editors/MediaController.cs
+++ b/src/Umbraco.Web/Editors/MediaController.cs
@@ -82,7 +82,7 @@ namespace Umbraco.Web.Editors
throw new HttpResponseException(HttpStatusCode.NotFound);
}
- var emptyContent = Services.MediaService.CreateMedia("", parentId, contentType.Alias, Security.GetUserId().ResultOr(0));
+ var emptyContent = Services.MediaService.CreateMedia("", parentId, contentType.Alias, Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
var mapped = Mapper.Map(emptyContent);
//remove the listview app if it exists
@@ -447,7 +447,7 @@ namespace Umbraco.Web.Editors
//if the current item is in the recycle bin
if (foundMedia.Trashed == false)
{
- var moveResult = Services.MediaService.MoveToRecycleBin(foundMedia, (int)Security.CurrentUser.Id);
+ var moveResult = Services.MediaService.MoveToRecycleBin(foundMedia, Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
if (moveResult == false)
{
//returning an object of INotificationModel will ensure that any pending
@@ -457,7 +457,7 @@ namespace Umbraco.Web.Editors
}
else
{
- var deleteResult = Services.MediaService.Delete(foundMedia, (int)Security.CurrentUser.Id);
+ var deleteResult = Services.MediaService.Delete(foundMedia, Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
if (deleteResult == false)
{
//returning an object of INotificationModel will ensure that any pending
@@ -481,7 +481,7 @@ namespace Umbraco.Web.Editors
var destinationParentID = move.ParentId;
var sourceParentID = toMove.ParentId;
- var moveResult = Services.MediaService.Move(toMove, move.ParentId);
+ var moveResult = Services.MediaService.Move(toMove, move.ParentId, Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
if (sourceParentID == destinationParentID)
{
@@ -557,7 +557,7 @@ namespace Umbraco.Web.Editors
}
//save the item
- var saveStatus = Services.MediaService.Save(contentItem.PersistedContent, (int)Security.CurrentUser.Id);
+ var saveStatus = Services.MediaService.Save(contentItem.PersistedContent, Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
//return the updated model
var display = Mapper.Map(contentItem.PersistedContent);
@@ -603,7 +603,7 @@ namespace Umbraco.Web.Editors
[HttpPost]
public HttpResponseMessage EmptyRecycleBin()
{
- Services.MediaService.EmptyRecycleBin();
+ Services.MediaService.EmptyRecycleBin(Security.GetUserId().ResultOr(Constants.Security.SuperUserId));
return Request.CreateNotificationSuccessResponse(Services.TextService.Localize("defaultdialogs/recycleBinIsEmpty"));
}