From d8a3e00440f785552e183203a3eb7a13f022a858 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 27 Mar 2014 17:26:55 +1100 Subject: [PATCH] Fixes: U4-2843 Copying Document Type when Selecting Master Doesn't Work (Master ignored), U4-3552 Copy nested document type is failing --- .../umbraco/dialogs/moveOrCopy.aspx.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs index 0e515da061..42bc8b9bc9 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Globalization; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml; @@ -58,10 +59,10 @@ namespace umbraco.dialogs masterType.Items.Add(new ListItem(ui.Text("none") + "...", "0")); foreach (var docT in DocumentType.GetAllAsList()) { - masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString())); + masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString(CultureInfo.InvariantCulture))); } - masterType.SelectedValue = documentType.MasterContentType.ToString(); + masterType.SelectedValue = documentType.MasterContentType.ToString(CultureInfo.InvariantCulture); rename.Text = documentType.Text + " (copy)"; pane_settings.Text = "Make a copy of the document type '" + documentType.Text + "' and save it under a new name"; @@ -146,6 +147,9 @@ namespace umbraco.dialogs private void HandleDocumentTypeCopy() { + + //TODO: This should be a method on the service!!! + var contentTypeService = ApplicationContext.Current.Services.ContentTypeService; var contentType = contentTypeService.GetContentType( int.Parse(Request.GetItemAsString("id"))); @@ -153,6 +157,20 @@ namespace umbraco.dialogs var alias = rename.Text.Trim().Replace("'", "''"); var clone = ((Umbraco.Core.Models.ContentType) contentType).Clone(alias); clone.Name = rename.Text.Trim(); + + //set the master + //http://issues.umbraco.org/issue/U4-2843 + //http://issues.umbraco.org/issue/U4-3552 + var parent = int.Parse(masterType.SelectedValue); + if (parent > 0) + { + clone.ParentId = parent; + } + else + { + clone.ParentId = -1; + } + contentTypeService.Save(clone); var returnUrl = string.Format("{0}/settings/editNodeTypeNew.aspx?id={1}", SystemDirectories.Umbraco, clone.Id);