diff --git a/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs b/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs index 144b147cd6c..0d4253d26a1 100644 --- a/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs +++ b/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs @@ -96,5 +96,9 @@ protected override void Importing(ContainablePart part, ImportContentContext con protected override void Exporting(ContainablePart part, ExportContentContext context) { context.Element(part.PartDefinition.Name).SetAttributeValue("Position", part.Position); } + + protected override void Cloning(ContainablePart originalPart, ContainablePart clonePart, CloneContentContext context) { + clonePart.Position = originalPart.Position; + } } } diff --git a/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs b/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs index 3de8e78e669..8ad150d4a0b 100644 --- a/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs +++ b/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs @@ -179,5 +179,17 @@ protected override void Exporting(ContainerPart part, ExportContentContext conte context.Element(part.PartDefinition.Name).SetAttributeValue("AdminMenuImageSet", part.AdminMenuImageSet); context.Element(part.PartDefinition.Name).SetAttributeValue("ItemCount", part.ItemCount); } + + protected override void Cloning(ContainerPart originalPart, ContainerPart clonePart, CloneContentContext context) { + clonePart.ItemContentTypes = originalPart.ItemContentTypes; + clonePart.ItemsShown = originalPart.ItemsShown; + clonePart.Paginated = originalPart.Paginated; + clonePart.PageSize = originalPart.PageSize; + clonePart.ShowOnAdminMenu = originalPart.ShowOnAdminMenu; + clonePart.AdminMenuText = originalPart.AdminMenuText; + clonePart.AdminMenuPosition = originalPart.AdminMenuPosition; + clonePart.AdminMenuImageSet = originalPart.AdminMenuImageSet; + clonePart.ItemCount = originalPart.ItemCount; + } } } diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs index 40592468e96..cf2bfc956f3 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -404,7 +404,7 @@ private ActionResult EditPOST(int id, string returnUrl, Func } [HttpPost] - public ActionResult Clone(int id) { + public ActionResult Clone(int id, string returnUrl) { var originalContentItem = _contentManager.GetLatest(id); if (!Services.Authorizer.Authorize(Permissions.ViewContent, originalContentItem, T("You do not have permission to view existing content."))) @@ -425,8 +425,13 @@ public ActionResult Clone(int id) { ? T("The content has been cloned as a draft.") : T("The {0} has been cloned as a draft.", originalContentItem.TypeDefinition.DisplayName)); - var adminRouteValues = _contentManager.GetItemMetadata(cloneContentItem).AdminRouteValues; - return RedirectToRoute(adminRouteValues); + if (string.IsNullOrWhiteSpace(returnUrl)) { + var adminRouteValues = _contentManager.GetItemMetadata(cloneContentItem).AdminRouteValues; + return RedirectToRoute(adminRouteValues); + } + else { + return this.RedirectLocal(returnUrl, () => RedirectToAction("List")); + } } [HttpPost] diff --git a/src/Orchard.Web/Core/Navigation/Drivers/AdminMenuPartDriver.cs b/src/Orchard.Web/Core/Navigation/Drivers/AdminMenuPartDriver.cs index 473542408dd..0e48e13f838 100644 --- a/src/Orchard.Web/Core/Navigation/Drivers/AdminMenuPartDriver.cs +++ b/src/Orchard.Web/Core/Navigation/Drivers/AdminMenuPartDriver.cs @@ -1,6 +1,7 @@ using System; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; using Orchard.Core.Navigation.Models; using Orchard.Core.Navigation.Settings; using Orchard.Localization; @@ -94,5 +95,11 @@ protected override void Exporting(AdminMenuPart part, ContentManagement.Handlers context.Element(part.PartDefinition.Name).SetAttributeValue("AdminMenuPosition", part.AdminMenuPosition); context.Element(part.PartDefinition.Name).SetAttributeValue("OnAdminMenu", part.OnAdminMenu); } + + protected override void Cloning(AdminMenuPart originalPart, AdminMenuPart clonePart, CloneContentContext context) { + clonePart.AdminMenuText = originalPart.AdminMenuText; + clonePart.AdminMenuPosition = originalPart.AdminMenuPosition; + clonePart.OnAdminMenu = originalPart.OnAdminMenu; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Navigation/Drivers/MenuItemPartDriver.cs b/src/Orchard.Web/Core/Navigation/Drivers/MenuItemPartDriver.cs index 5da805c8d9d..b2b780aba73 100644 --- a/src/Orchard.Web/Core/Navigation/Drivers/MenuItemPartDriver.cs +++ b/src/Orchard.Web/Core/Navigation/Drivers/MenuItemPartDriver.cs @@ -1,5 +1,6 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; using Orchard.Core.Navigation.Models; using Orchard.Security; @@ -50,5 +51,9 @@ protected override void Importing(MenuItemPart part, ContentManagement.Handlers. protected override void Exporting(MenuItemPart part, ContentManagement.Handlers.ExportContentContext context) { context.Element(part.PartDefinition.Name).SetAttributeValue("Url", part.Url); } + + protected override void Cloning(MenuItemPart originalPart, MenuItemPart clonePart, CloneContentContext context) { + clonePart.Url = originalPart.Url; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs b/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs index 613554455c7..dfbdda3176a 100644 --- a/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs +++ b/src/Orchard.Web/Core/Navigation/Drivers/MenuPartDriver.cs @@ -1,6 +1,7 @@ using System.Linq; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; using Orchard.Core.Navigation.Models; using Orchard.Core.Navigation.Services; using Orchard.Core.Navigation.ViewModels; @@ -114,5 +115,11 @@ protected override void Exporting(MenuPart part, ContentManagement.Handlers.Expo context.Element(part.PartDefinition.Name).SetAttributeValue("MenuText", part.MenuText); context.Element(part.PartDefinition.Name).SetAttributeValue("MenuPosition", part.MenuPosition); } + + protected override void Cloning(MenuPart originalPart, MenuPart clonePart, CloneContentContext context) { + clonePart.MenuText = originalPart.MenuText; + clonePart.MenuPosition = originalPart.MenuPosition; + clonePart.Menu = context.CloneContentItem; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Navigation/Drivers/MenuWidgetPartDriver.cs b/src/Orchard.Web/Core/Navigation/Drivers/MenuWidgetPartDriver.cs index 626a6669125..790bc6ad822 100644 --- a/src/Orchard.Web/Core/Navigation/Drivers/MenuWidgetPartDriver.cs +++ b/src/Orchard.Web/Core/Navigation/Drivers/MenuWidgetPartDriver.cs @@ -223,5 +223,15 @@ protected override void Exporting(MenuWidgetPart part, ExportContentContext cont context.Element(part.PartDefinition.Name).SetAttributeValue("ShowFullMenu", part.ShowFullMenu); } + protected override void Cloning(MenuWidgetPart originalPart, MenuWidgetPart clonePart, CloneContentContext context) { + clonePart.StartLevel = originalPart.StartLevel; + clonePart.Levels = originalPart.Levels; + clonePart.Breadcrumb = originalPart.Breadcrumb; + clonePart.AddCurrentPage = originalPart.AddCurrentPage; + clonePart.AddHomePage = originalPart.AddHomePage; + clonePart.ShowFullMenu = originalPart.ShowFullMenu; + clonePart.MenuContentItemId = originalPart.MenuContentItemId; + } + } } diff --git a/src/Orchard.Web/Core/Navigation/Drivers/ShapeMenuItemPartDriver.cs b/src/Orchard.Web/Core/Navigation/Drivers/ShapeMenuItemPartDriver.cs index 61dd7cde077..ad7fdf9a23b 100644 --- a/src/Orchard.Web/Core/Navigation/Drivers/ShapeMenuItemPartDriver.cs +++ b/src/Orchard.Web/Core/Navigation/Drivers/ShapeMenuItemPartDriver.cs @@ -48,5 +48,9 @@ protected override void Importing(ShapeMenuItemPart part, ImportContentContext c protected override void Exporting(ShapeMenuItemPart part, ExportContentContext context) { context.Element(part.PartDefinition.Name).SetAttributeValue("ShapeType", part.ShapeType); } + + protected override void Cloning(ShapeMenuItemPart originalPart, ShapeMenuItemPart clonePart, CloneContentContext context) { + clonePart.ShapeType = originalPart.ShapeType; + } } } diff --git a/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/SpamFilterPartDriver.cs b/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/SpamFilterPartDriver.cs index 772f515a345..09f5b8ae39c 100644 --- a/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/SpamFilterPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/SpamFilterPartDriver.cs @@ -51,5 +51,10 @@ protected override void Importing(SpamFilterPart part, ImportContentContext cont protected override void Exporting(SpamFilterPart part, ExportContentContext context) { context.Element(part.PartDefinition.Name).SetAttributeValue("Status", part.Status.ToString()); } + + protected override void Cloning(SpamFilterPart originalPart, SpamFilterPart clonePart, CloneContentContext context) { + clonePart.Status = originalPart.Status; + } + } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Drivers/ArchiveLaterPartDriver.cs b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Drivers/ArchiveLaterPartDriver.cs index 48899fd37c1..7d4a4f339d9 100644 --- a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Drivers/ArchiveLaterPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Drivers/ArchiveLaterPartDriver.cs @@ -109,5 +109,10 @@ protected override void Exporting(ArchiveLaterPart part, ExportContentContext co .SetAttributeValue("ScheduledArchiveUtc", XmlConvert.ToString(scheduled.Value, XmlDateTimeSerializationMode.Utc)); } } + + protected override void Cloning(ArchiveLaterPart originalPart, ArchiveLaterPart clonePart, CloneContentContext context) { + clonePart.ScheduledArchiveUtc.Value = originalPart.ScheduledArchiveUtc.Value; + } + } } diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs index 06e6ae49666..209fd0810fa 100644 --- a/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs @@ -177,5 +177,11 @@ protected override void Exporting(AutoroutePart part, ExportContentContext conte context.Element(part.PartDefinition.Name).SetAttributeValue("UseCulturePattern", part.Record.UseCulturePattern); context.Element(part.PartDefinition.Name).SetAttributeValue("PromoteToHomePage", part.PromoteToHomePage); } + + protected override void Cloning(AutoroutePart originalPart, AutoroutePart clonePart, CloneContentContext context) { + clonePart.CustomPattern = originalPart.CustomPattern; + clonePart.UseCustomPattern = originalPart.UseCustomPattern; + clonePart.UseCulturePattern = originalPart.UseCulturePattern; + } } } diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogArchivesPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogArchivesPartDriver.cs index 5ea0c3d1fcc..bea7c120852 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogArchivesPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogArchivesPartDriver.cs @@ -13,7 +13,7 @@ public class BlogArchivesPartDriver : ContentPartDriver { private readonly IContentManager _contentManager; public BlogArchivesPartDriver( - IBlogService blogService, + IBlogService blogService, IBlogPostService blogPostService, IContentManager contentManager) { _blogService = blogService; @@ -37,7 +37,7 @@ protected override DriverResult Editor(BlogArchivesPart part, dynamic shapeHelpe var viewModel = new BlogArchivesViewModel { BlogId = part.BlogId, Blogs = _blogService.Get().ToList().OrderBy(b => _contentManager.GetItemMetadata(b).DisplayText) - }; + }; return ContentShape("Parts_Blogs_BlogArchives_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.BlogArchives", Model: viewModel, Prefix: Prefix)); @@ -69,5 +69,8 @@ protected override void Exporting(BlogArchivesPart part, ExportContentContext co context.Element(part.PartDefinition.Name).SetAttributeValue("Blog", blogIdentity); } + protected override void Cloning(BlogArchivesPart originalPart, BlogArchivesPart clonePart, CloneContentContext context) { + clonePart.BlogId = originalPart.BlogId; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogPartDriver.cs index d9dddbe4acc..a2d6122fa9c 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogPartDriver.cs @@ -3,6 +3,7 @@ using Orchard.Blogs.Models; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; namespace Orchard.Blogs.Drivers { public class BlogPartDriver : ContentPartDriver { @@ -66,5 +67,11 @@ protected override void Exporting(BlogPart part, ContentManagement.Handlers.Expo context.Element(part.PartDefinition.Name).SetAttributeValue("PostCount", part.PostCount); context.Element(part.PartDefinition.Name).SetAttributeValue("FeedProxyUrl", part.FeedProxyUrl); } + + protected override void Cloning(BlogPart originalPart, BlogPart clonePart, CloneContentContext context) { + clonePart.Description = originalPart.Description; + clonePart.PostCount = originalPart.PostCount; + clonePart.FeedProxyUrl = originalPart.FeedProxyUrl; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs index 91d19aea182..abcc743a91d 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/RecentBlogPostsPartDriver.cs @@ -87,5 +87,10 @@ protected override void Exporting(RecentBlogPostsPart part, ExportContentContext context.Element(part.PartDefinition.Name).SetAttributeValue("Blog", blogIdentity); context.Element(part.PartDefinition.Name).SetAttributeValue("Count", part.Count); } + + protected override void Cloning(RecentBlogPostsPart originalPart, RecentBlogPostsPart clonePart, CloneContentContext context) { + clonePart.BlogId = originalPart.BlogId; + clonePart.Count = originalPart.Count; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs index cd79d4b4f69..3d03b3262f3 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentPartDriver.cs @@ -9,6 +9,7 @@ using Orchard.Localization; using Orchard.Comments.Services; using Orchard.UI.Notify; +using Orchard.ContentManagement.Handlers; namespace Orchard.Comments.Drivers { public class CommentPartDriver : ContentPartDriver { @@ -227,5 +228,33 @@ protected override void Exporting(CommentPart part, ContentManagement.Handlers.E } } } + + protected override void Cloning(CommentPart originalPart, CommentPart clonePart, CloneContentContext context) { + clonePart.Author = originalPart.Author; + clonePart.SiteName = originalPart.SiteName; + clonePart.UserName = originalPart.UserName; + clonePart.Email = originalPart.Email; + clonePart.Position = originalPart.Position; + clonePart.Status = originalPart.Status; + clonePart.CommentDateUtc = originalPart.CommentDateUtc; + clonePart.CommentText = originalPart.CommentText; + var commentedOn = _contentManager.Get(originalPart.CommentedOn); + if (commentedOn != null) { + clonePart.CommentedOn = originalPart.CommentedOn; + } + if (originalPart.RepliedOn.HasValue) { + var repliedOn = _contentManager.Get(originalPart.RepliedOn.Value); + if (repliedOn != null) { + clonePart.RepliedOn = originalPart.RepliedOn; + } + } + else { + clonePart.RepliedOn = null; + } + var commentedOnContainer = _contentManager.Get(originalPart.CommentedOnContainer); + if (commentedOnContainer != null) { + clonePart.CommentedOnContainer = originalPart.CommentedOnContainer; + } + } } } diff --git a/src/Orchard.Web/Modules/Orchard.ContentPermissions/Drivers/ContentPermissionsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.ContentPermissions/Drivers/ContentPermissionsPartDriver.cs index c10971e256b..f3326aa7e1d 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentPermissions/Drivers/ContentPermissionsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentPermissions/Drivers/ContentPermissionsPartDriver.cs @@ -185,6 +185,20 @@ protected override void Importing(ContentPermissionsPart part, ImportContentCont context.ImportAttribute(part.PartDefinition.Name, "PreviewOwnContent", s => part.PreviewOwnContent = s); } + protected override void Cloning(ContentPermissionsPart originalPart, ContentPermissionsPart clonePart, CloneContentContext context) { + clonePart.Enabled = originalPart.Enabled; + clonePart.ViewContent = originalPart.ViewContent; + clonePart.EditContent = originalPart.EditContent; + clonePart.PublishContent = originalPart.PublishContent; + clonePart.DeleteContent = originalPart.DeleteContent; + clonePart.PreviewContent = originalPart.PreviewContent; + clonePart.ViewOwnContent = originalPart.ViewOwnContent; + clonePart.EditOwnContent = originalPart.EditOwnContent; + clonePart.PublishOwnContent = originalPart.PublishOwnContent; + clonePart.DeleteOwnContent = originalPart.DeleteOwnContent; + clonePart.PreviewOwnContent = originalPart.PreviewOwnContent; + } + private void OverrideDefaultPermissions(ContentPermissionsPart part, List allRoles, ContentPermissionsPartSettings settings) { // reset permissions the user can't change if (!_authorizer.Authorize(Core.Contents.Permissions.ViewContent, part.ContentItem)) { diff --git a/src/Orchard.Web/Modules/Orchard.ContentPicker/Drivers/ContentMenuItemPartDriver.cs b/src/Orchard.Web/Modules/Orchard.ContentPicker/Drivers/ContentMenuItemPartDriver.cs index 3ce50ed99be..3952a8cc2e9 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentPicker/Drivers/ContentMenuItemPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentPicker/Drivers/ContentMenuItemPartDriver.cs @@ -85,5 +85,9 @@ protected override void Exporting(ContentMenuItemPart part, ExportContentContext } } } + + protected override void Cloning(ContentMenuItemPart originalPart, ContentMenuItemPart clonePart, CloneContentContext context) { + clonePart.Content = originalPart.Content; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/AudioPartDriver.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/AudioPartDriver.cs index 859db198be0..d9339d3043c 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/AudioPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/AudioPartDriver.cs @@ -27,6 +27,7 @@ protected override void Importing(AudioPart part, ContentManagement.Handlers.Imp part.Length = int.Parse(length) ); } + protected override void Cloning(AudioPart originalPart, AudioPart clonePart, CloneContentContext context) { clonePart.Length = originalPart.Length; } diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/DocumentPartDriver.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/DocumentPartDriver.cs index 0ef73494240..9c4333266fd 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/DocumentPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/DocumentPartDriver.cs @@ -27,6 +27,7 @@ protected override void Importing(DocumentPart part, ContentManagement.Handlers. part.Length = int.Parse(length) ); } + protected override void Cloning(DocumentPart originalPart, DocumentPart clonePart, CloneContentContext context) { clonePart.Length = originalPart.Length; } diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/MediaPartDriver.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/MediaPartDriver.cs index 6aa91d1d9b0..2ac0a26e043 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/MediaPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/MediaPartDriver.cs @@ -76,12 +76,12 @@ protected override void Exporting(MediaPart part, ContentManagement.Handlers.Exp } protected override void Cloning(MediaPart originalPart, MediaPart clonePart, CloneContentContext context) { + clonePart.MimeType = originalPart.MimeType; clonePart.Caption = originalPart.Caption; - clonePart.FileName = originalPart.FileName; + clonePart.AlternateText = originalPart.AlternateText; clonePart.FolderPath = originalPart.FolderPath; + clonePart.FileName = originalPart.FileName; clonePart.LogicalType = originalPart.LogicalType; - clonePart.AlternateText = originalPart.AlternateText; - clonePart.MimeType = originalPart.MimeType; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/OEmbedPartDriver.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/OEmbedPartDriver.cs index 81da1f09b3d..2f501684059 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/OEmbedPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/OEmbedPartDriver.cs @@ -76,6 +76,6 @@ protected override void Cloning(OEmbedPart originalPart, OEmbedPart clonePart, C cloneElement.Add(partCloneElement); partCloneElement.Add(partOriginalElement.Elements()); } - } + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.MediaProcessing/Drivers/ImageProfilePartDriver.cs b/src/Orchard.Web/Modules/Orchard.MediaProcessing/Drivers/ImageProfilePartDriver.cs index 4eaed50a2ce..5d20d91c91f 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaProcessing/Drivers/ImageProfilePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaProcessing/Drivers/ImageProfilePartDriver.cs @@ -106,5 +106,12 @@ protected override void Importing(ImageProfilePart part, ImportContentContext co part.Record.Filters.Add(result); } } + + protected override void Cloning(ImageProfilePart originalPart, ImageProfilePart clonePart, CloneContentContext context) { + clonePart.Name = originalPart.Name; + clonePart.ModifiedUtc = originalPart.ModifiedUtc; + clonePart.Record.Filters = originalPart.Filters; + clonePart.Record.FileNames = originalPart.FileNames; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/NavigationQueryPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/NavigationQueryPartDriver.cs index 0babaebc07c..b92d67a41c9 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/NavigationQueryPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/NavigationQueryPartDriver.cs @@ -83,5 +83,14 @@ protected override void Exporting(NavigationQueryPart part, ExportContentContext } } } + + protected override void Cloning(NavigationQueryPart originalPart, NavigationQueryPart clonePart, CloneContentContext context) { + clonePart.Items = originalPart.Items; + clonePart.Skip = originalPart.Skip; + } + + protected override void Cloned(NavigationQueryPart originalPart, NavigationQueryPart clonePart, CloneContentContext context) { + clonePart.QueryPartRecord = originalPart.QueryPartRecord; + } } } diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs index 9d9a4f74091..a412d17f647 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs @@ -280,5 +280,11 @@ private PropertyRecord GetProperty(XElement property) { ZeroIsEmpty = Convert.ToBoolean(property.Attribute("ZeroIsEmpty").Value), }; } + + protected override void Cloning(QueryPart originalPart, QueryPart clonePart, CloneContentContext context) { + clonePart.Record.SortCriteria = originalPart.SortCriteria; + clonePart.Record.FilterGroups = originalPart.FilterGroups; + clonePart.Record.Layouts = originalPart.Layouts; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs b/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs index 9efc3e4d9c0..1594eaee42d 100644 --- a/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs @@ -134,5 +134,9 @@ protected override void Exporting(PublishLaterPart part, ExportContentContext co .SetAttributeValue("ScheduledPublishUtc", XmlConvert.ToString(scheduled.Value, XmlDateTimeSerializationMode.Utc)); } } + + protected override void Cloning(PublishLaterPart originalPart, PublishLaterPart clonePart, CloneContentContext context) { + clonePart.ScheduledPublishUtc.Value = originalPart.ScheduledPublishUtc.Value; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Drivers/UserRolesPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Roles/Drivers/UserRolesPartDriver.cs index 8c2c7a45495..7bcadf83396 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Drivers/UserRolesPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Roles/Drivers/UserRolesPartDriver.cs @@ -10,6 +10,7 @@ using Orchard.Roles.ViewModels; using Orchard.Security; using Orchard.UI.Notify; +using Orchard.ContentManagement.Handlers; namespace Orchard.Roles.Drivers { public class UserRolesPartDriver : ContentPartDriver { @@ -127,5 +128,17 @@ protected override void Importing(UserRolesPart part, ContentManagement.Handlers protected override void Exporting(UserRolesPart part, ContentManagement.Handlers.ExportContentContext context) { context.Element(part.PartDefinition.Name).SetAttributeValue("Roles", string.Join(",", part.Roles)); } + + protected override void Cloning(UserRolesPart originalPart, UserRolesPart clonePart, CloneContentContext context) { + var cloneRoleRecords = _userRolesRepository + .Fetch(x => x.UserId == clonePart.ContentItem.Id) + .ToList() + .Select(x => x.Role) + .ToList(); + var origRoleRecords = originalPart.Roles.Select(x => _roleService.GetRoleByName(x)).ToList(); + foreach (var addingRole in origRoleRecords.Where(x => !cloneRoleRecords.Contains(x))) { + _userRolesRepository.Create(new UserRolesPartRecord { UserId = clonePart.ContentItem.Id, Role = addingRole }); + } + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchFormPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchFormPartDriver.cs index 20915d493f4..6f8cb451d09 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchFormPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchFormPartDriver.cs @@ -56,5 +56,10 @@ protected override void Importing(SearchFormPart part, ImportContentContext cont context.ImportAttribute(part.PartDefinition.Name, "OverrideIndex", x => part.OverrideIndex = XmlHelper.Parse(x)); context.ImportAttribute(part.PartDefinition.Name, "SelectedIndex", x => part.SelectedIndex = x); } + + protected override void Cloning(SearchFormPart originalPart, SearchFormPart clonePart, CloneContentContext context) { + clonePart.OverrideIndex = originalPart.OverrideIndex; + clonePart.SelectedIndex = originalPart.SelectedIndex; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchSettingsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchSettingsPartDriver.cs index 86f8f4db737..b566d4e7b77 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchSettingsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Drivers/SearchSettingsPartDriver.cs @@ -89,5 +89,9 @@ protected override void Importing(SearchSettingsPart part, ImportContentContext part.Store("SearchFields", value); }); } + + protected override void Cloning(SearchSettingsPart originalPart, SearchSettingsPart clonePart, CloneContentContext context) { + clonePart.SearchFields = originalPart.SearchFields; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagCloudDriver.cs b/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagCloudDriver.cs index eb3fe1538dc..dbdb9936479 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagCloudDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Tags/Drivers/TagCloudDriver.cs @@ -51,5 +51,10 @@ protected override void Importing(TagCloudPart part, ImportContentContext contex part.Slug = context.Attribute(part.PartDefinition.Name, "Slug"); part.Buckets = Convert.ToInt32(context.Attribute(part.PartDefinition.Name, "Buckets")); } + + protected override void Cloning(TagCloudPart originalPart, TagCloudPart clonePart, CloneContentContext context) { + clonePart.Slug = originalPart.Slug; + clonePart.Buckets = originalPart.Buckets; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyNavigationPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyNavigationPartDriver.cs index 6cd72a5dfcc..f950344997b 100644 --- a/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyNavigationPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyNavigationPartDriver.cs @@ -131,5 +131,14 @@ protected override void Importing(TaxonomyNavigationPart part, ImportContentCont part.TermId = term.Id; } } + + protected override void Cloning(TaxonomyNavigationPart originalPart, TaxonomyNavigationPart clonePart, CloneContentContext context) { + clonePart.DisplayContentCount = originalPart.DisplayContentCount; + clonePart.DisplayRootTerm = originalPart.DisplayRootTerm; + clonePart.HideEmptyTerms = originalPart.HideEmptyTerms; + clonePart.LevelsToDisplay = originalPart.LevelsToDisplay; + clonePart.TaxonomyId = originalPart.TaxonomyId; + clonePart.TermId = originalPart.TermId; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs index dbd29f8a16f..03c34227781 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Drivers/ShapePartDriver.cs @@ -101,6 +101,11 @@ protected override void Importing(ShapePart part, ImportContentContext context) } } + protected override void Cloning(ShapePart originalPart, ShapePart clonePart, CloneContentContext context) { + clonePart.Template = originalPart.Template; + clonePart.RenderingMode = originalPart.RenderingMode; + } + private bool ValidateShapeName(ShapePart part, IUpdateModel updater) { var titleViewModel = new TitleViewModel(); if (!updater.TryUpdateModel(titleViewModel, "Title", null, null)) diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs index 7c686031e89..4fe0325f5a5 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs @@ -91,5 +91,11 @@ protected override void Exporting(LayerPart part, ExportContentContext context) context.Element(part.PartDefinition.Name).SetAttributeValue("Description", part.Description); context.Element(part.PartDefinition.Name).SetAttributeValue("LayerRule", part.LayerRule); } + + protected override void Cloning(LayerPart originalPart, LayerPart clonePart, CloneContentContext context) { + clonePart.Name = originalPart.Name; + clonePart.Description = originalPart.Description; + clonePart.LayerRule = originalPart.LayerRule; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs index 7d474bb1617..a3f8142aabe 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; using Orchard.Localization; using Orchard.Utility.Extensions; using Orchard.Widgets.Models; @@ -104,5 +105,14 @@ protected override void Exporting(WidgetPart part, ContentManagement.Handlers.Ex context.Element(part.PartDefinition.Name).SetAttributeValue("Name", part.Name); context.Element(part.PartDefinition.Name).SetAttributeValue("CssClasses", part.CssClasses); } + + protected override void Cloning(WidgetPart originalPart, WidgetPart clonePart, CloneContentContext context) { + clonePart.Title = originalPart.Title; + clonePart.Position = originalPart.Position; + clonePart.Zone = originalPart.Zone; + clonePart.RenderTitle = originalPart.RenderTitle; + clonePart.Name = originalPart.Name; + clonePart.CssClasses = originalPart.CssClasses; + } } } diff --git a/src/Orchard/ContentManagement/Drivers/Coordinators/ContentPartDriverCoordinator.cs b/src/Orchard/ContentManagement/Drivers/Coordinators/ContentPartDriverCoordinator.cs index 10efd58ee82..f7e21651bd3 100644 --- a/src/Orchard/ContentManagement/Drivers/Coordinators/ContentPartDriverCoordinator.cs +++ b/src/Orchard/ContentManagement/Drivers/Coordinators/ContentPartDriverCoordinator.cs @@ -97,12 +97,14 @@ public override void Exported(ExportContentContext context) { } public override void Cloning(CloneContentContext context) { + context.Logger = Logger; foreach (var contentPartDriver in _drivers) { contentPartDriver.Cloning(context); } } public override void Cloned(CloneContentContext context) { + context.Logger = Logger; foreach (var contentPartDriver in _drivers) { contentPartDriver.Cloned(context); }