From 17906b505d10ee48fc52211adffd606f41757a4e Mon Sep 17 00:00:00 2001 From: AndyButland Date: Sun, 18 Jan 2015 21:13:24 +0100 Subject: [PATCH 01/18] Removed code in tree synchronisation that removes anchor tag containing node name for certain nodes --- .../src/common/directives/umbtreeitem.directive.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js index b08476ee77..9a34b26aec 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js @@ -88,10 +88,6 @@ angular.module("umbraco.directives") element.find("a:first").html(node.name); - if (!node.menuUrl) { - element.find("a:last").remove(); - } - if (node.style) { element.find("i:first").attr("style", node.style); } From 4775b638a43b67468c8492eb4bf829986b0dbf52 Mon Sep 17 00:00:00 2001 From: AndyButland Date: Mon, 19 Jan 2015 08:05:32 +0100 Subject: [PATCH 02/18] Reverted previous commit and changed anchor removal to target the correct tag (the elipsis) --- .../src/common/directives/umbtreeitem.directive.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js index 9a34b26aec..a202a2c7a7 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbtreeitem.directive.js @@ -88,6 +88,10 @@ angular.module("umbraco.directives") element.find("a:first").html(node.name); + if (!node.menuUrl) { + element.find("a.umb-options").remove(); + } + if (node.style) { element.find("i:first").attr("style", node.style); } From 12d51b292c6f92edbdad4a58a436e5b27d66c318 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 19 Jan 2015 13:40:21 +0100 Subject: [PATCH 03/18] U4-6154 - fix unpublishing a document with changes Conflicts: src/Umbraco.Core/Services/ContentService.cs --- .../Repositories/ContentRepository.cs | 11 +++ .../Interfaces/IContentRepository.cs | 6 ++ .../Publishing/PublishingStrategy.cs | 93 +++++++------------ src/Umbraco.Core/Services/ContentService.cs | 8 ++ 4 files changed, 61 insertions(+), 57 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index d89fc79dbe..c23095ebd6 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -631,6 +631,17 @@ namespace Umbraco.Core.Persistence.Repositories repo.ReplaceEntityPermissions(permissionSet); } + public void ClearPublished(IContent content) + { + // race cond! + var documentDtos = Database.Fetch("WHERE nodeId=@id AND published=@published", new { id = content.Id, published = true }); + foreach (var documentDto in documentDtos) + { + documentDto.Published = false; + Database.Update(documentDto); + } + } + public IContent GetByLanguage(int id, string language) { var sql = GetBaseQuery(false); diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs index ac0fcebbe7..5cb470b7cd 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs @@ -27,6 +27,12 @@ namespace Umbraco.Core.Persistence.Repositories /// void ReplaceContentPermissions(EntityPermissionSet permissionSet); + /// + /// Clears the published flag for a content. + /// + /// + void ClearPublished(IContent content); + /// /// Gets a specific language version of an /// diff --git a/src/Umbraco.Core/Publishing/PublishingStrategy.cs b/src/Umbraco.Core/Publishing/PublishingStrategy.cs index 899567bf8d..1c33f87c5e 100644 --- a/src/Umbraco.Core/Publishing/PublishingStrategy.cs +++ b/src/Umbraco.Core/Publishing/PublishingStrategy.cs @@ -303,32 +303,7 @@ namespace Umbraco.Core.Publishing /// True if the unpublish operation was successfull and not cancelled, otherwise false public override bool UnPublish(IContent content, int userId) { - if (UnPublishing.IsRaisedEventCancelled(new PublishEventArgs(content), this)) - { - LogHelper.Info( - string.Format("Content '{0}' with Id '{1}' will not be un-published, the event was cancelled.", content.Name, content.Id)); - return false; - } - - - //If Content has a release date set to before now, it should be removed so it doesn't interrupt an unpublish - //Otherwise it would remain released == published - if (content.ReleaseDate.HasValue && content.ReleaseDate.Value <= DateTime.Now) - { - content.ReleaseDate = null; - - LogHelper.Info( - string.Format( - "Content '{0}' with Id '{1}' had its release date removed, because it was unpublished.", - content.Name, content.Id)); - } - - content.ChangePublishedState(PublishedState.Unpublished); - - LogHelper.Info( - string.Format("Content '{0}' with Id '{1}' has been unpublished.", - content.Name, content.Id)); - return true; + return UnPublishInternal(content, userId).Success; } /// @@ -337,43 +312,47 @@ namespace Umbraco.Core.Publishing /// An enumerable list of /// Id of the User issueing the unpublish operation /// A list of publish statuses - internal IEnumerable> UnPublishInternal(IEnumerable content, int userId) + private IEnumerable> UnPublishInternal(IEnumerable content, int userId) { - var result = new List>(); + return content.Select(x => UnPublishInternal(x, userId)); + } - //Only update content thats already been published - foreach (var item in content.Where(x => x.Published == true)) + private Attempt UnPublishInternal(IContent content, int userId) + { + // content should (is assumed to ) be the newest version, which may not be published + // don't know how to test this, so it's not verified + // NOTE + // if published != newest, then the published flags need to be reseted by whoever is calling that method + // at the moment it's done by the content service + + //Fire UnPublishing event + if (UnPublishing.IsRaisedEventCancelled(new PublishEventArgs(content), this)) { - //Fire UnPublishing event - if (UnPublishing.IsRaisedEventCancelled(new PublishEventArgs(item), this)) - { - LogHelper.Info( - string.Format("Content '{0}' with Id '{1}' will not be published, the event was cancelled.", item.Name, item.Id)); - result.Add(Attempt.Fail(new PublishStatus(item, PublishStatusType.FailedCancelledByEvent))); - continue; - } - - //If Content has a release date set to before now, it should be removed so it doesn't interrupt an unpublish - //Otherwise it would remain released == published - if (item.ReleaseDate.HasValue && item.ReleaseDate.Value <= DateTime.Now) - { - item.ReleaseDate = null; - - LogHelper.Info( - string.Format("Content '{0}' with Id '{1}' had its release date removed, because it was unpublished.", - item.Name, item.Id)); - } - - item.ChangePublishedState(PublishedState.Unpublished); - LogHelper.Info( - string.Format("Content '{0}' with Id '{1}' has been unpublished.", - item.Name, item.Id)); - - result.Add(Attempt.Succeed(new PublishStatus(item))); + string.Format("Content '{0}' with Id '{1}' will not be unpublished, the event was cancelled.", content.Name, content.Id)); + return Attempt.Fail(new PublishStatus(content, PublishStatusType.FailedCancelledByEvent)); } - return result; + //If Content has a release date set to before now, it should be removed so it doesn't interrupt an unpublish + //Otherwise it would remain released == published + if (content.ReleaseDate.HasValue && content.ReleaseDate.Value <= DateTime.Now) + { + content.ReleaseDate = null; + + LogHelper.Info( + string.Format("Content '{0}' with Id '{1}' had its release date removed, because it was unpublished.", + content.Name, content.Id)); + } + + // if newest is published, unpublish + if (content.Published) + content.ChangePublishedState(PublishedState.Unpublished); + + LogHelper.Info( + string.Format("Content '{0}' with Id '{1}' has been unpublished.", + content.Name, content.Id)); + + return Attempt.Succeed(new PublishStatus(content)); } /// diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 93069b7bd9..95ef869d3b 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1686,6 +1686,11 @@ namespace Umbraco.Core.Services /// True if unpublishing succeeded, otherwise False private bool UnPublishDo(IContent content, bool omitCacheRefresh = false, int userId = 0) { + content = GetById(content.Id); // ensure we have the newest version + var published = content.Published ? content : GetPublishedVersion(content.Id); // get the published version + if (published == null) + return false; // already unpublished + var unpublished = _publishingStrategy.UnPublish(content, userId); if (unpublished) { @@ -1694,6 +1699,9 @@ namespace Umbraco.Core.Services { content.WriterId = userId; repository.AddOrUpdate(content); + // is published is not newest, reset the published flag on published version + if (published.Version != content.Version) + repository.ClearPublished(published); repository.DeleteContentXml(content); uow.Commit(); From 7b4a82eb8d6cbcdc2899f9c40103b77e34e8422c Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 20 Jan 2015 19:57:13 +0100 Subject: [PATCH 04/18] U4-6154 - bugfix --- src/Umbraco.Core/Services/ContentService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 95ef869d3b..966ae9f0e7 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1686,7 +1686,9 @@ namespace Umbraco.Core.Services /// True if unpublishing succeeded, otherwise False private bool UnPublishDo(IContent content, bool omitCacheRefresh = false, int userId = 0) { - content = GetById(content.Id); // ensure we have the newest version + var newest = GetById(content.Id); // ensure we have the newest version + if (content.Version != newest.Version) // but use the original object if it's already the newest version + content = newest; var published = content.Published ? content : GetPublishedVersion(content.Id); // get the published version if (published == null) return false; // already unpublished From 44257e361afb17fa653fc1b7923f18f0b77a4af3 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 21 Jan 2015 10:41:01 +1100 Subject: [PATCH 05/18] Fixes refs to Microsoft.Net.Http --- src/Umbraco.Core/Umbraco.Core.csproj | 6 ++++++ src/Umbraco.Core/packages.config | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 11 +++++++++++ src/Umbraco.Tests/packages.config | 4 +++- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 11 +++++++++++ src/Umbraco.Web.UI/packages.config | 4 +++- src/Umbraco.Web/Umbraco.Web.csproj | 11 +++++++++++ src/Umbraco.Web/packages.config | 4 +++- src/umbraco.MacroEngines/packages.config | 4 +++- src/umbraco.MacroEngines/umbraco.MacroEngines.csproj | 11 +++++++++++ 10 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 851e573670..0562ca4e8b 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -84,10 +84,16 @@ + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll False + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + diff --git a/src/Umbraco.Core/packages.config b/src/Umbraco.Core/packages.config index f01b9e68ba..f3f9b617f7 100644 --- a/src/Umbraco.Core/packages.config +++ b/src/Umbraco.Core/packages.config @@ -9,7 +9,7 @@ - + diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index de66f44f79..c3690bad2c 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -111,9 +111,15 @@ + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + @@ -723,6 +729,11 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\x86\*.* "$(TargetDir)x86\" /Y /F /E /D + + + + + + + + + + \ No newline at end of file diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 9adab52a05..05e2b17ca2 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -14,7 +14,9 @@ - + + + diff --git a/src/umbraco.MacroEngines/packages.config b/src/umbraco.MacroEngines/packages.config index ca995d7c13..8d9f3cdb4c 100644 --- a/src/umbraco.MacroEngines/packages.config +++ b/src/umbraco.MacroEngines/packages.config @@ -10,7 +10,9 @@ - + + + diff --git a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj index f6b611a6c8..2b874a155e 100644 --- a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj +++ b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj @@ -74,9 +74,15 @@ + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + @@ -233,6 +239,11 @@ + + + + +