diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index fa90a61110..26f99b22b1 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -422,6 +422,12 @@ ImageViewer.ascx + + create.aspx + + + create.aspx + PartialView.ascx ASPXCodeBehind @@ -581,6 +587,7 @@ treeInit.aspx + diff --git a/src/Umbraco.Web.UI/umbraco/Create.aspx.cs b/src/Umbraco.Web.UI/umbraco/Create.aspx.cs new file mode 100644 index 0000000000..304e7ffdb1 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/Create.aspx.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Xml; +using Umbraco.Core; +using Umbraco.Core.IO; +using umbraco.cms.presentation.Trees; + +namespace Umbraco.Web.UI.Umbraco +{ + public partial class CreateDialog : global::umbraco.cms.presentation.Create + { + + protected override void OnLoad(EventArgs e) + { + if (SecurityCheck(Request.QueryString["nodeType"])) + { + //if we're allowed, then continue + base.OnLoad(e); + } + else + { + //otherwise show an error + UI.Visible = false; + AccessError.Visible = true; + } + } + + private bool SecurityCheck(string nodeTypeAlias) + { + return LegacyDialogHandler.UserHasCreateAccess( + new HttpContextWrapper(Context), + getUser(), + nodeTypeAlias); + } + + } +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/Create.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/Create.aspx.designer.cs new file mode 100644 index 0000000000..1e11eaf00d --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/Create.aspx.designer.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// 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.Web.UI.Umbraco { + + + public partial class CreateDialog + { + + /// + /// AccessError control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.PlaceHolder AccessError; + } +} diff --git a/src/Umbraco.Web.UI/umbraco/create.aspx b/src/Umbraco.Web.UI/umbraco/create.aspx new file mode 100644 index 0000000000..782b7f178d --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/create.aspx @@ -0,0 +1,43 @@ +<%@ Page Language="c#" MasterPageFile="masterpages/umbracoDialog.Master" Codebehind="CreateDialog.aspx.cs" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Umbraco.CreateDialog" %> +<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %> + + + + + + + + + +
+

+ The current user does not have access to create this type of object +

+
+
+
+ + + + \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index ebc2a01006..d6c4f74347 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -373,6 +373,9 @@ + + ASPXCodeBehind + diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs new file mode 100644 index 0000000000..2be60fd598 --- /dev/null +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs @@ -0,0 +1,48 @@ +using System; +using System.Web.UI.WebControls; + +using System.Xml; +using Umbraco.Core.IO; + +namespace umbraco.cms.presentation +{ + public class Create : BasePages.UmbracoEnsuredPage + { + protected Label helpText; + protected TextBox rename; + protected Label Label1; + protected ListBox nodeType; + protected PlaceHolder UI; + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + // Load create definitions + var nodeType = Request.QueryString["nodeType"]; + + var createDef = new XmlDocument(); + var defReader = new XmlTextReader(IOHelper.MapPath(SystemFiles.CreateUiXml)); + createDef.Load(defReader); + defReader.Close(); + + // Find definition for current nodeType + var def = createDef.SelectSingleNode("//nodeType [@alias = '" + nodeType + "']"); + if (def == null) + { + throw new ArgumentException("The create dialog for \"" + nodeType + "\" does not match anything defined in the \"" + SystemFiles.CreateUiXml + "\". This could mean an incorrectly installed package or a corrupt UI file"); + } + + try + { + var virtualPath = SystemDirectories.Umbraco + def.SelectSingleNode("./usercontrol").FirstChild.Value; + var mainControl = LoadControl(virtualPath); + UI.Controls.Add(mainControl); + } + catch (Exception ex) + { + throw new ArgumentException("ERROR CREATING CONTROL FOR NODETYPE: " + nodeType, ex); + } + } + } +}