diff --git a/src/Umbraco.Core/EmbeddedResources/Lang/en.xml b/src/Umbraco.Core/EmbeddedResources/Lang/en.xml index 0a8b03b115..77f8543491 100644 --- a/src/Umbraco.Core/EmbeddedResources/Lang/en.xml +++ b/src/Umbraco.Core/EmbeddedResources/Lang/en.xml @@ -1178,7 +1178,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont has been selected as the root of your new content, click 'ok' below. No node selected yet, please select a node in the list above before clicking 'ok' The current node is not allowed under the chosen node because of its type - The current node cannot be moved to one of its subpages + The current node cannot be moved to one of its subpages neither can the parent and destination be the same The current node cannot exist at the root The action isn't allowed since you have insufficient permissions on 1 or more child documents. diff --git a/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml b/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml index 88030198a3..f193518c24 100644 --- a/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml +++ b/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml @@ -1203,7 +1203,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont has been selected as the root of your new content, click 'ok' below. No node selected yet, please select a node in the list above before clicking 'ok' The current node is not allowed under the chosen node because of its type - The current node cannot be moved to one of its subpages + The current node cannot be moved to one of its subpages neither can the parent and destination be the same The current node cannot exist at the root The action isn't allowed since you have insufficient permissions on 1 or more child documents. diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 63a05dcd6e..915b92d78d 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -2432,6 +2432,11 @@ public class ContentService : RepositoryService, IContentService /// Optional Id of the User moving the Content public void Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId) { + if(content.ParentId == parentId) + { + return; + } + // if moving to the recycle bin then use the proper method if (parentId == Constants.System.RecycleBinContent) { diff --git a/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs b/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs index 98a7195fbf..7cf63445a9 100644 --- a/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs +++ b/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs @@ -845,6 +845,10 @@ public abstract class ContentTypeServiceBase : ContentTypeSe public Attempt?> Move(TItem moving, int containerId) { EventMessages eventMessages = EventMessagesFactory.Get(); + if(moving.ParentId == containerId) + { + return OperationResult.Attempt.Fail(MoveOperationStatusType.FailedNotAllowedByPath, eventMessages); + } var moveInfo = new List>(); using (ICoreScope scope = ScopeProvider.CreateCoreScope()) diff --git a/src/Umbraco.Core/Services/DataTypeService.cs b/src/Umbraco.Core/Services/DataTypeService.cs index d310954985..de3f96d834 100644 --- a/src/Umbraco.Core/Services/DataTypeService.cs +++ b/src/Umbraco.Core/Services/DataTypeService.cs @@ -396,6 +396,11 @@ namespace Umbraco.Cms.Core.Services.Implement public Attempt?> Move(IDataType toMove, int parentId) { EventMessages evtMsgs = EventMessagesFactory.Get(); + if (toMove.ParentId == parentId) + { + return OperationResult.Attempt.Fail(MoveOperationStatusType.FailedNotAllowedByPath, evtMsgs); + } + var moveInfo = new List>(); using (ICoreScope scope = ScopeProvider.CreateCoreScope()) diff --git a/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs b/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs index b9508a501b..8b25275508 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs @@ -260,6 +260,11 @@ public class DictionaryController : BackOfficeNotificationsController return ValidationProblem(_localizedTextService.Localize("dictionary", "itemDoesNotExists")); } + if(dictionaryItem.ParentId == null && move.ParentId == Constants.System.Root) + { + return ValidationProblem(_localizedTextService.Localize("moveOrCopy", "notAllowedByPath")); + } + IDictionaryItem? parent = _localizationService.GetDictionaryItemById(move.ParentId); if (parent == null) { @@ -274,6 +279,11 @@ public class DictionaryController : BackOfficeNotificationsController } else { + if (dictionaryItem.ParentId == parent.Key) + { + return ValidationProblem(_localizedTextService.Localize("moveOrCopy", "notAllowedByPath")); + } + dictionaryItem.ParentId = parent.Key; if (dictionaryItem.Key == parent.ParentId) { diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index ada64bd3f6..dfac875e5e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -432,15 +432,13 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter, loca throw "args.id cannot be null"; } - var promise = localizationService.localize("contentType_moveFailed"); - return umbRequestHelper.resourcePromise( $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostMove"), { parentId: args.parentId, id: args.id }, { responseType: 'text' }), - promise); + 'Failed to move content type'); }, /** diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js index 62fe2b7367..79f35d0d74 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js @@ -208,15 +208,13 @@ function mediaTypeResource($q, $http, umbRequestHelper, umbDataFormatter, locali throw "args.id cannot be null"; } - var promise = localizationService.localize("mediaType_moveFailed"); - return umbRequestHelper.resourcePromise( $http.post(umbRequestHelper.getApiUrl("mediaTypeApiBaseUrl", "PostMove"), { parentId: args.parentId, id: args.id }, { responseType: 'text' }), - promise); + 'Failed to move media type'); }, copy: function (args) {