diff --git a/umbraco/businesslogic/IO/SystemFiles.cs b/umbraco/businesslogic/IO/SystemFiles.cs index 48c30aaba9..00f108d847 100644 --- a/umbraco/businesslogic/IO/SystemFiles.cs +++ b/umbraco/businesslogic/IO/SystemFiles.cs @@ -15,7 +15,7 @@ namespace umbraco.IO { get { - return SystemDirectories.Data + "/access.xml"; + return SystemDirectories.Data + "/access.config"; } } diff --git a/umbraco/cms/businesslogic/member/MemberGroup.cs b/umbraco/cms/businesslogic/member/MemberGroup.cs index 0e26157590..7d4307274a 100644 --- a/umbraco/cms/businesslogic/member/MemberGroup.cs +++ b/umbraco/cms/businesslogic/member/MemberGroup.cs @@ -2,6 +2,7 @@ using System; using System.Data; using umbraco.DataLayer; using System.Collections; +using umbraco.cms.businesslogic.web; namespace umbraco.cms.businesslogic.member { @@ -15,6 +16,7 @@ namespace umbraco.cms.businesslogic.member public class MemberGroup : CMSNode { private static Guid _objectType = new Guid("366e63b9-880f-4e13-a61c-98069b029728"); + private string _oldGroupName; /// /// Initialize a new object of the MemberGroup class @@ -34,6 +36,20 @@ namespace umbraco.cms.businesslogic.member } + public override string Text + { + get + { + return base.Text; + } + set + { + // in order to be able to update access.xml if name changes we need to store a reference to the old name + _oldGroupName = Text; + base.Text = value; + } + } + /// /// Deltes the current membergroup /// @@ -62,6 +78,12 @@ namespace umbraco.cms.businesslogic.member SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); + // if the name has changed we need to update the public access + if (_oldGroupName != Text) + { + Access.RenameMemberShipRole(_oldGroupName, Text); + } + if (!e.Cancel) { FireAfterSave(e); } diff --git a/umbraco/cms/businesslogic/web/Access.cs b/umbraco/cms/businesslogic/web/Access.cs index c76ddc162a..022f58e9d5 100644 --- a/umbraco/cms/businesslogic/web/Access.cs +++ b/umbraco/cms/businesslogic/web/Access.cs @@ -180,6 +180,24 @@ namespace umbraco.cms.businesslogic.web new Access().FireAfterRemoveMemberShipRoleFromDocument(new Document(documentId), role, e); } } + + public static bool RenameMemberShipRole(string oldRolename, string newRolename) + { + bool hasChange = false; + if (oldRolename != newRolename) + { + foreach (XmlNode x in AccessXml.SelectNodes("//group [@id = '" + oldRolename + "']")) + { + x.Attributes["id"].Value = newRolename; + hasChange = true; + } + if (hasChange) + save(); + } + + return hasChange; + + } public static void ProtectPage(bool Simple, int DocumentId, int LoginDocumentId, int ErrorDocumentId) { diff --git a/umbraco/presentation/install/default.aspx.cs b/umbraco/presentation/install/default.aspx.cs index 5a87ec4eab..9b54c50936 100644 --- a/umbraco/presentation/install/default.aspx.cs +++ b/umbraco/presentation/install/default.aspx.cs @@ -107,13 +107,21 @@ namespace umbraco.presentation.install loadContent(); break; case "detect": - step.Value = "validatePermissions"; + // upgrade! + if (!String.IsNullOrEmpty(GlobalSettings.ConfigurationStatus.Trim())) + step.Value = "renaming"; + else + step.Value = "validatePermissions"; loadContent(); break; case "upgradeIndex": step.Value = "validatePermissions"; loadContent(); break; + case "renaming" : + step.Value = "validatePermissions"; + loadContent(); + break; case "validatePermissions": step.Value = "defaultUser"; loadContent(); diff --git a/umbraco/presentation/install/steps/renaming.ascx b/umbraco/presentation/install/steps/renaming.ascx new file mode 100644 index 0000000000..0e782032ab --- /dev/null +++ b/umbraco/presentation/install/steps/renaming.ascx @@ -0,0 +1,25 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="renaming.ascx.cs" Inherits="umbraco.presentation.install.steps.renaming" %> +

Step 3/5: Updating old conventions

+ +

+ This version of Umbraco introduces new conventions for naming XSLT and REST extensions as well as a renaming of the Public Access storage file.
+ You no longer need to prefix your extension references with /bin and the public access storage file is now called access.config instead of access.xml.
+ This step of the installer will try to update your old references. If it fails due to permission settings, you'll need to make these changes manually! +

+ + +

Everything looks good. No changes needed for the upgrade, just press next.

+
+ +

+The following changes will need to be made. Press to update changes button to proceed: +

+ + +
+
+ + + + \ No newline at end of file diff --git a/umbraco/presentation/install/steps/renaming.ascx.cs b/umbraco/presentation/install/steps/renaming.ascx.cs new file mode 100644 index 0000000000..2603e24dff --- /dev/null +++ b/umbraco/presentation/install/steps/renaming.ascx.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.IO; +using System.Xml; +using umbraco.IO; + +namespace umbraco.presentation.install.steps +{ + public partial class renaming : System.Web.UI.UserControl + { + private string _oldAccessFilePath = IO.IOHelper.MapPath(IO.SystemDirectories.Data + "/access.xml"); + private bool _changesNeeded = false; + + protected void Page_Load(object sender, EventArgs e) + { + // check xslt extensions + identifyResult.Text += checkExtensionPaths("xsltExtensions.config", "XSLT Extension"); + + // check rest extensions + identifyResult.Text += checkExtensionPaths("restExtensions.config", "REST Extension"); + + // check access.xml file + identifyResult.Text += checkAccessFile(); + + if (_changesNeeded) + { + changesNeeded.Visible = true; + } + else + { + noChangedNeeded.Visible = true; + changesNeeded.Visible = false; + } + } + + private string checkAccessFile() + { + if (oldAccessFileExist()) + { + _changesNeeded = true; + return "
  • Access.xml found. Needs to be renamed to access.config
  • "; + } + else + { + return "
  • Public Access file is all good. No changes needed
  • "; + } + } + + private bool oldAccessFileExist() + { + return File.Exists(_oldAccessFilePath); + } + + private string checkExtensionPaths(string filename, string extensionName) + { + string tempResult = ""; + foreach (XmlNode ext in GetExtensions(filename, "ext")) + { + if (ext.Attributes.GetNamedItem("assembly") != null && + ext.Attributes.GetNamedItem("assembly").Value.StartsWith("/bin/")) + { + tempResult += String.Format("
  • {0} with Alias '{1}' has assembly reference that contains /bin/. That part needs to be removed
  • ", + extensionName, + ext.Attributes.GetNamedItem("alias").Value); + } + } + + if (String.IsNullOrEmpty(tempResult)) + { + tempResult = String.Format("
  • {0}s are all good. No changes needed
  • ", extensionName); + } + else + { + _changesNeeded = true; + } + + return tempResult; + } + + private void updateExtensionPaths(string filename) + { + filename = IOHelper.MapPath(SystemDirectories.Config + "/" + filename); + XmlDocument xsltExt = new XmlDocument(); + xsltExt.Load(filename); + + foreach (XmlNode ext in xsltExt.SelectNodes("//ext")) + { + if (ext.Attributes.GetNamedItem("assembly") != null && + ext.Attributes.GetNamedItem("assembly").Value.StartsWith("/bin/")) + { + ext.Attributes.GetNamedItem("assembly").Value = + ext.Attributes.GetNamedItem("assembly").Value.Substring(5); + } + } + + xsltExt.Save(filename); + + } + + + protected void updateChanges_Click(object sender, EventArgs e) + { + bool succes = true; + string progressText = ""; + + // rename access file + if (oldAccessFileExist()) + { + try + { + File.Move(_oldAccessFilePath, IO.IOHelper.MapPath(IO.SystemFiles.AccessXml)); + progressText += String.Format("
  • Public Access file renamed
  • "); + } + catch (Exception ee) + { + progressText += String.Format("
  • Error renaming access file: {0}
  • ", ee.ToString()); + succes = false; + } + } + + // update rest exts + try + { + updateExtensionPaths("restExtensions.config"); + progressText += "
  • restExtensions.config ensured.
  • "; + } + catch (Exception ee) + { + progressText += String.Format("
  • Error updating restExtensions.config: {0}
  • ", ee.ToString()); + succes = false; + } + + // update xslt exts + try + { + updateExtensionPaths("xsltExtensions.config"); + progressText += "
  • xsltExtensions.config ensured.
  • "; + } + catch (Exception ee) + { + progressText += String.Format("
  • Error updating xsltExtensions.config: {0}
  • ", ee.ToString()); + succes = false; + } + + string resultClass = succes ? "success" : "error"; + resultText.Text = String.Format("

    {1}

    ", + resultClass, + progressText); + result.Visible = true; + init.Visible = false; + } + + private XmlNodeList GetExtensions(string filename, string elementName) + { + + // Load the XSLT extensions configuration + XmlDocument xsltExt = new XmlDocument(); + xsltExt.Load(IOHelper.MapPath(SystemDirectories.Config + "/" + filename)); + + return xsltExt.SelectNodes("//" + elementName); + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/install/steps/renaming.ascx.designer.cs b/umbraco/presentation/install/steps/renaming.ascx.designer.cs new file mode 100644 index 0000000000..26929da57b --- /dev/null +++ b/umbraco/presentation/install/steps/renaming.ascx.designer.cs @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.presentation.install.steps { + + + public partial class renaming { + + /// + /// init control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel init; + + /// + /// noChangedNeeded control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel noChangedNeeded; + + /// + /// changesNeeded control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel changesNeeded; + + /// + /// identifyResult control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal identifyResult; + + /// + /// updateChanges control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button updateChanges; + + /// + /// result control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel result; + + /// + /// resultText control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal resultText; + } +} diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index 5010dc026a..39d85ae53b 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -267,6 +267,13 @@ license.ascx + + renaming.ascx + ASPXCodeBehind + + + renaming.ascx + theend.ascx ASPXCodeBehind @@ -1497,6 +1504,7 @@ + diff --git a/umbraco/presentation/umbracobase/restExtension.cs b/umbraco/presentation/umbracobase/restExtension.cs index 12cf6e45c3..637c993b99 100644 --- a/umbraco/presentation/umbracobase/restExtension.cs +++ b/umbraco/presentation/umbracobase/restExtension.cs @@ -107,7 +107,7 @@ namespace umbraco.presentation.umbracobase { XmlNode extNode = baseDoc.SelectSingleNode("/RestExtensions/ext [@alias='" + extensionAlias + "']"); string asml = extNode.Attributes["assembly"].Value; - string assemblyPath = IOHelper.MapPath((SystemDirectories.Root + "/" + asml.TrimStart('/') + ".dll")); + string assemblyPath = IOHelper.MapPath(string.Format("{0}/{1}.dll", SystemDirectories.Bin, asml.TrimStart('/'))); Assembly returnAssembly = System.Reflection.Assembly.LoadFrom(assemblyPath); string returnTypeName = extNode.Attributes["type"].Value;