diff --git a/src/SQLCE4Umbraco/Sql/Total.sql b/src/SQLCE4Umbraco/Sql/Total.sql index 6b7fe6ee87..6a57d2f8dc 100644 --- a/src/SQLCE4Umbraco/Sql/Total.sql +++ b/src/SQLCE4Umbraco/Sql/Total.sql @@ -10,7 +10,7 @@ IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - Database version: 4.10.0.0 + Database version: 4.8.0.2 Please increment this version number if ANY change is made to this script, so compatibility with scripts for other database systems can be verified easily. @@ -146,18 +146,12 @@ CREATE TABLE [cmsContentType] [pk] [int] NOT NULL IDENTITY(1, 1), [nodeId] [int] NOT NULL, [alias] [nvarchar] (255) NULL, -[icon] [nvarchar] (255) NULL, -[isContainer] bit NOT NULL CONSTRAINT [DF_cmsContentType_isContainer] DEFAULT (0), -[allowAtRoot] bit NOT NULL CONSTRAINT [DF_cmsContentType_allowAtRoot] DEFAULT (0) +[icon] [nvarchar] (255) NULL ) ; ALTER TABLE [cmsContentType] ADD CONSTRAINT [PK_cmsContentType] PRIMARY KEY ([pk]) ; -CREATE TABLE [cmsContentType2ContentType] ([parentContentTypeId] int NOT NULL,[childContentTypeId] int NOT NULL) -; -ALTER TABLE [cmsContentType2ContentType] ADD CONSTRAINT [cmsContentType2ContentType_PK] PRIMARY KEY ([parentContentTypeId],[childContentTypeId]) -; CREATE TABLE [cmsMacroPropertyType] ( [id] [int] NOT NULL IDENTITY(1, 1), @@ -189,19 +183,16 @@ ALTER TABLE [umbracoStylesheetProperty] ADD CONSTRAINT [PK_stylesheetProperty] P */ -CREATE TABLE [cmsPropertyTypeGroup] +CREATE TABLE [cmsTab] ( [id] [int] NOT NULL IDENTITY(1, 1), [contenttypeNodeId] [int] NOT NULL, [text] [nvarchar] (255) NOT NULL, -[sortorder] [int] NOT NULL, -[parentGroupId] int NULL CONSTRAINT [DF_cmsPropertyTypeGroup_parentGroupId] DEFAULT NULL +[sortorder] [int] NOT NULL ) ; -ALTER TABLE [cmsPropertyTypeGroup] ADD CONSTRAINT [PK_cmsPropertyTypeGroup] PRIMARY KEY ([id]) -; -ALTER TABLE [cmsPropertyTypeGroup] ADD CONSTRAINT [FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup] FOREIGN KEY([parentGroupId]) REFERENCES [cmsPropertyTypeGroup] ([id]) +ALTER TABLE [cmsTab] ADD CONSTRAINT [PK_cmsTab] PRIMARY KEY ([id]) ; CREATE TABLE [cmsTemplate] ( @@ -309,7 +300,7 @@ CREATE TABLE [cmsPropertyType] [id] [int] NOT NULL IDENTITY(1, 1), [dataTypeId] [int] NOT NULL, [contentTypeId] [int] NOT NULL, -[propertyTypeGroupId] int, +[tabId] [int] NULL, [Alias] [nvarchar] (255) NOT NULL, [Name] [nvarchar] (255) NULL, [helpText] [nvarchar] (1000) NULL, @@ -386,8 +377,7 @@ ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [PK_umbracoAppTree] PRIMARY KEY ([a CREATE TABLE [cmsContentTypeAllowedContentType] ( [Id] [int] NOT NULL, -[AllowedId] [int] NOT NULL, -[sortOrder] int NOT NULL CONSTRAINT [DF_cmsContentTypeAllowedContentType_sortOrder] DEFAULT (1) +[AllowedId] [int] NOT NULL ) ; @@ -587,6 +577,9 @@ CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbra ALTER TABLE [cmsContentType] ADD CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) ; +ALTER TABLE [cmsPropertyType] ADD +CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) +; ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) ; @@ -600,6 +593,8 @@ CONSTRAINT [FK_umbracoUser2app_umbracoApp] FOREIGN KEY ([app]) REFERENCES [umbra ALTER TABLE [cmsTemplate] DROP CONSTRAINT [FK_cmsTemplate_umbracoNode] ; +ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab] +; ALTER TABLE [cmsContent] DROP CONSTRAINT [FK_cmsContent_umbracoNode] ; ALTER TABLE [cmsMacroProperty] DROP CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] @@ -731,22 +726,22 @@ ALTER TABLE [umbracoNode] DROP CONSTRAINT [FK_umbracoNode_umbracoNode] |INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (25, N'textMultiLine', N'umbraco.macroRenderings', N'textMultiple', N'String') |SET IDENTITY_INSERT [cmsMacroPropertyType] OFF ; -!!!SET IDENTITY_INSERT [cmsPropertyTypeGroup] ON -|INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1) -|INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1) -|INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1) -|SET IDENTITY_INSERT [cmsPropertyTypeGroup] OFF +!!!SET IDENTITY_INSERT [cmsTab] ON +|INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1) +|INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1) +|INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1) +|SET IDENTITY_INSERT [cmsTab] OFF ; !!!SET IDENTITY_INSERT [cmsPropertyType] ON -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) -|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) +|INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL) |SET IDENTITY_INSERT [cmsPropertyType] OFF ; !!!SET IDENTITY_INSERT [umbracoLanguage] ON @@ -796,6 +791,8 @@ INSERT INTO [cmsContentTypeAllowedContentType] ([Id], [AllowedId]) VALUES (1031, ; ALTER TABLE [cmsTemplate] ADD CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) ; +ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) +; ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) ; ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id]) @@ -928,6 +925,10 @@ INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, VALUES (0, 1, 2, 'translation','yourTasks', 'Tasks created by you', '.sprTreeFolder', '.sprTreeFolder_o', 'umbraco', 'loadYourTasks'); ; */ +alter TABLE [cmsContentType] +add [masterContentType] int NULL CONSTRAINT +[DF_cmsContentType_masterContentType] DEFAULT (0) +; CREATE TABLE [cmsTagRelationship]( [nodeId] [int] NOT NULL, [tagId] [int] NOT NULL) @@ -961,10 +962,11 @@ CREATE TABLE [cmsPreviewXml]( [versionId] [uniqueidentifier] NOT NULL, [timestamp] [datetime] NOT NULL, [xml] [ntext] NOT NULL) - ; + + /*********************************************************************************************************************** ADD NEW PRIMARY KEYS, FOREIGN KEYS AND INDEXES FOR VERSION 4.1 @@ -989,7 +991,7 @@ ALTER TABLE [umbracoUserType] ALTER COLUMN id IDENTITY(5,1) ; ALTER TABLE [cmsMacroPropertyType] ALTER COLUMN id IDENTITY(26,1) ; -ALTER TABLE [cmsPropertyTypeGroup] ALTER COLUMN id IDENTITY(6,1) +ALTER TABLE [cmsTab] ALTER COLUMN id IDENTITY(6,1) ; ALTER TABLE [cmsPropertyType] ALTER COLUMN id IDENTITY(28,1) ; diff --git a/src/SQLCE4Umbraco/Sql/Version4_8_Upgrade.sql b/src/SQLCE4Umbraco/Sql/Version4_8_Upgrade.sql deleted file mode 100644 index 3295f407ae..0000000000 --- a/src/SQLCE4Umbraco/Sql/Version4_8_Upgrade.sql +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************************* - - Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) - - IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - - Database version: 4.10.0.0 - - Please increment this version number if ANY change is made to this script, - so compatibility with scripts for other database systems can be verified easily. - The first 3 digits depict the Umbraco version, the last digit is the database version. - (e.g. version 4.0.0.3 means "Umbraco version 4.0.0, database version 3") - - Check-in policy: only commit this script if - * you ran the Umbraco installer completely; - * you ran it on the targetted database system; - * you ran the Runway and Module installations; - * you were able to browse the Boost site; - * you were able to open the Umbraco administration panel; - * you have documented the code change in this script; - * you have incremented the version number in this script. - - IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - -********************************************************************************************/ --- rename cmsTab -SP_RENAME 'cmsTab', 'cmsPropertyTypeGroup' -; --- add parent Group to new cmsPropertyTypeGroup -ALTER TABLE [cmsPropertyTypeGroup] -ADD [parentGroupId] int NULL -CONSTRAINT [DF_cmsPropertyTypeGroup_parentGroupId] DEFAULT NULL -; -ALTER TABLE [cmsPropertyTypeGroup] -ADD CONSTRAINT [FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup] FOREIGN KEY([parentGroupId]) -REFERENCES [cmsPropertyTypeGroup] ([id]) -; --- add sortOrder to cmsContentTypeAllowedContentType -ALTER TABLE [cmsContentTypeAllowedContentType] -ADD [sortOrder] int NOT NULL -CONSTRAINT [DF_cmsContentTypeAllowedContentType_sortOrder] DEFAULT 1 -; --- add container and allowAtRoot to cmsContentType -ALTER TABLE [cmsContentType] -ADD [isContainer] bit NOT NULL -CONSTRAINT [DF_cmsContentType_isContainer] DEFAULT 0 -; -ALTER TABLE [cmsContentType] -ADD [allowAtRoot] bit NOT NULL -CONSTRAINT [DF_cmsContentType_allowAtRoot] DEFAULT 0 -; -CREATE TABLE [cmsContentType2ContentType] ([parentContentTypeId] int NOT NULL,[childContentTypeId] int NOT NULL) -; -ALTER TABLE [cmsContentType2ContentType] ADD CONSTRAINT [cmsContentType2ContentType_PK] PRIMARY KEY ([parentContentTypeId],[childContentTypeId]) -; --- move all masterContentType information to new cmsContentType2ContentType table -INSERT INTO [cmsContentType2ContentType] (parentContentTypeId, childContentTypeId) -select masterContentType, nodeId from [cmsContentType] WHERE not [masterContentType] is null and [masterContentType] != 0 -; -ALTER TABLE [cmsContentType] DROP COLUMN [masterContentType] -; --- rename tab to propertyGroup on propertyType -ALTER TABLE [cmsPropertyType] ADD [propertyTypeGroupId] int -; -UPDATE [cmsPropertyType] SET [propertyTypeGroupId] = [tabId] -; -ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab] -; -ALTER TABLE [cmsPropertyType] DROP COLUMN [tabId] -; diff --git a/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj b/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj index 442f9497c3..58e0f3fff4 100644 --- a/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj +++ b/src/SQLCE4Umbraco/SqlCE4Umbraco.csproj @@ -73,7 +73,6 @@ - diff --git a/src/SQLCE4Umbraco/SqlCEInstaller.cs b/src/SQLCE4Umbraco/SqlCEInstaller.cs index 24184578cd..0d60c20288 100644 --- a/src/SQLCE4Umbraco/SqlCEInstaller.cs +++ b/src/SQLCE4Umbraco/SqlCEInstaller.cs @@ -22,14 +22,11 @@ namespace SqlCE4Umbraco #region Private Constants /// The latest database version this installer supports. - private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_9; + private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8; /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'cmsContentType2ContentType'", 1, DatabaseVersion.Version4_9), - //This will throw an exception and will only ever have one row if it is installed, on exception the database version returned is unkown so will still work. - //NOTE: before this was set to zero and only worked by fluke! - new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 1, DatabaseVersion.Version4_8), + new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 0, DatabaseVersion.Version4_8), new VersionSpecs("SELECT id FROM umbracoNode WHERE id = -21", 1, DatabaseVersion.Version4_1), new VersionSpecs("SELECT action FROM umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("SELECT description FROM cmsContentType",DatabaseVersion.Version3), diff --git a/src/SQLCE4Umbraco/SqlCEResources.resx b/src/SQLCE4Umbraco/SqlCEResources.resx index 479fca991b..cb62be9b84 100644 --- a/src/SQLCE4Umbraco/SqlCEResources.resx +++ b/src/SQLCE4Umbraco/SqlCEResources.resx @@ -124,7 +124,4 @@ sql\version4_1_upgrade.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - - sql\version4_8_upgrade.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - \ No newline at end of file diff --git a/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs b/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs index 5fa612bc71..7c443f7c2b 100644 --- a/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs +++ b/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs @@ -103,24 +103,5 @@ namespace SQLCE4Umbraco { return ResourceManager.GetString("Version4_1_Upgrade", resourceCulture); } } - - /// - /// Looks up a localized string similar to /******************************************************************************************* - /// - /// Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) - /// - /// IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - /// - /// Database version: 4.8.0.0 - /// - /// Please increment this version number if ANY change is made to this script, - /// so compatibility with scripts for other database systems can be verified easily. - /// The first 3 digits depict [rest of string was truncated]";. - /// - internal static string Version4_8_Upgrade { - get { - return ResourceManager.GetString("Version4_8_Upgrade", resourceCulture); - } - } } } diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx index 6ace3a8cd4..e6119df965 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx @@ -1,5 +1,5 @@ -<%@ Control Language="c#" AutoEventWireup="True" CodeBehind="ContentTypeControlNew.ascx.cs" - Inherits="umbraco.controls.ContentTypeControlNew" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> +<%@ Control Language="c#" AutoEventWireup="True" Codebehind="ContentTypeControlNew.ascx.cs" + Inherits="umbraco.controls.ContentTypeControlNew" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> <%@ Register TagPrefix="cc2" Namespace="umbraco.uicontrols" Assembly="controls" %> @@ -9,107 +9,92 @@ - -

Master Content Type enabled
- This Content Type uses - as Master Content Type(s). Tabs from Master Content Types are not shown and can only be edited on the Master Content Type itself

-
- - - - -   - - - - - - - - - - - - - - - - - - - - - - - -

- -

-
+ +

Master Content Type enabled
This Content Type uses as a Master Content Type. Tabs from Master Content Types are not shown and can only be edited on the Master Content Type itself

+
+ + + +   + + + + + + + + + + + + + + + + + + + + + + +

+

+
- - - - - - - - - - - - - - -
- A Container Content Type hides it's children in the tree, and instead injects a list based overview of children to the editing pane -
- -
- -
-
- -
- -
-
- - - -
+ + + + + + + + + + + + + + +
+ +
+
+ +
+ +
+
+ + + +
- - -
- Only Content Types with this checked can be created at the root level of Content and Media trees -
- - - - -
+ + + + + +
- -

Master Content Type enabled
- This Content Type uses - as a Master Content Type. Properties from Master Content Types are not shown and can only be edited on the Master Content Type itself

-
- - -
+ +

Master Content Type enabled
This Content Type uses as a Master Content Type. Properties from Master Content Types are not shown and can only be edited on the Master Content Type itself

+
+ + +
-
+
+ \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs index 66cdc47845..f343f4adbe 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs @@ -241,7 +241,7 @@ function openContent(id) { } protected void SetSourcesAttributes(ref XmlTreeNode treeElement, Document dd) { - treeElement.HasChildren = !dd.ContentType.IsContainerContentType && dd.HasChildren; + treeElement.HasChildren = dd.HasChildren; if (!IsDialog) treeElement.Source = GetTreeServiceUrl(dd.Id); else diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs index 0041bf4c29..3937f8642a 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs @@ -78,7 +78,7 @@ function openNodeType(id) { if (base.m_id == -1) docTypes = DocumentType.GetAllAsList().FindAll(delegate(DocumentType dt) { return dt.MasterContentType == 0; }); else - docTypes = DocumentType.GetAllAsList().FindAll(delegate(DocumentType dt) { return dt.MasterContentTypes.Contains(base.m_id); }); + docTypes = DocumentType.GetAllAsList().FindAll(delegate(DocumentType dt) { return dt.MasterContentType == base.m_id; }); foreach (DocumentType dt in docTypes) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs index ab54690965..ccc43040aa 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs @@ -29,7 +29,6 @@ namespace umbraco.controls /// public class ContentControl : TabView { - private bool _hasContainer = false; private Content _content; private ArrayList _dataFields = new ArrayList(); private UmbracoEnsuredPage prntpage; @@ -94,14 +93,6 @@ namespace umbraco.controls if (virtualTabs == null) virtualTabs = _content.ContentType.getVirtualTabs.ToList(); - // Check for container - if (_content.ContentType.IsContainerContentType) - { - _hasContainer = true; - TabPage tp = NewTabPage("Children"); - addSaveAndPublishButtons(ref tp); - } - foreach (ContentType.TabI t in virtualTabs) { TabPage tp = NewTabPage(t.Caption); @@ -128,7 +119,7 @@ namespace umbraco.controls foreach (ContentType.TabI tab in virtualTabs) { - var tabPage = _hasContainer ? this.Panels[i+1] as TabPage : this.Panels[i] as TabPage; + var tabPage = this.Panels[i] as TabPage; if (tabPage == null) { throw new ArgumentException("Unable to load tab \"" + tab.Caption + "\""); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx index 6ace3a8cd4..e6119df965 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx @@ -1,5 +1,5 @@ -<%@ Control Language="c#" AutoEventWireup="True" CodeBehind="ContentTypeControlNew.ascx.cs" - Inherits="umbraco.controls.ContentTypeControlNew" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> +<%@ Control Language="c#" AutoEventWireup="True" Codebehind="ContentTypeControlNew.ascx.cs" + Inherits="umbraco.controls.ContentTypeControlNew" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> <%@ Register TagPrefix="cc2" Namespace="umbraco.uicontrols" Assembly="controls" %> @@ -9,107 +9,92 @@ - -

Master Content Type enabled
- This Content Type uses - as Master Content Type(s). Tabs from Master Content Types are not shown and can only be edited on the Master Content Type itself

-
- - - - -   - - - - - - - - - - - - - - - - - - - - - - - -

- -

-
+ +

Master Content Type enabled
This Content Type uses as a Master Content Type. Tabs from Master Content Types are not shown and can only be edited on the Master Content Type itself

+
+ + + +   + + + + + + + + + + + + + + + + + + + + + + +

+

+
- - - - - - - - - - - - - - -
- A Container Content Type hides it's children in the tree, and instead injects a list based overview of children to the editing pane -
- -
- -
-
- -
- -
-
- - - -
+ + + + + + + + + + + + + + +
+ +
+
+ +
+ +
+
+ + + +
- - -
- Only Content Types with this checked can be created at the root level of Content and Media trees -
- - - - -
+ + + + + +
- -

Master Content Type enabled
- This Content Type uses - as a Master Content Type. Properties from Master Content Types are not shown and can only be edited on the Master Content Type itself

-
- - -
+ +

Master Content Type enabled
This Content Type uses as a Master Content Type. Properties from Master Content Types are not shown and can only be edited on the Master Content Type itself

+
+ + +
-
+
+ \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index 3c5bd64e01..123ef70263 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -66,10 +66,6 @@ namespace umbraco.controls if (!HideStructure) { setupStructurePane(); - } else - { - // When we hide the structure, we'll also hide the container option (as we're on a member type) - pp_container.Visible = false; } setupGenericPropertiesPane(); setupTabPane(); @@ -93,23 +89,11 @@ namespace umbraco.controls pp_icon.Text = umbraco.ui.Text("icon", umbraco.BasePages.UmbracoEnsuredPage.CurrentUser); pp_thumbnail.Text = umbraco.ui.Text("editcontenttype", "thumbnail"); - // we'll disable this... - if (!Page.IsPostBack && cType.MasterContentTypes.Count > 0) - { - string masterName = String.Empty; - for(int i=0; i{1}", - cType.MasterContentTypes[i], - cms.businesslogic.ContentType.GetContentType(cType.MasterContentTypes[i]).Text); - if (i == cType.MasterContentTypes.Count-2) - masterName += " and "; - else if (cType.MasterContentTypes.Count > 1 && i < cType.MasterContentTypes.Count-1) - { - masterName += ", "; - } - } + // we'll disable this... + if (!Page.IsPostBack && cType.MasterContentType != 0) + { + string masterName = cms.businesslogic.ContentType.GetContentType(cType.MasterContentType).Text; tabsMasterContentTypeName.Text = masterName; propertiesMasterContentTypeName.Text = masterName; PaneTabsInherited.Visible = true; @@ -134,7 +118,6 @@ namespace umbraco.controls cType.IconUrl = ddlIcons.SelectedValue; cType.Description = description.Text; cType.Thumbnail = ddlThumbnails.SelectedValue; - cType.IsContainerContentType = isContainer.Checked; SaveClickEventArgs ea = new SaveClickEventArgs("Saved"); ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success; @@ -252,7 +235,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); txtName.Text = cType.GetRawText(); txtAlias.Text = cType.Alias; description.Text = cType.GetRawDescription(); - isContainer.Checked = cType.IsContainerContentType; } #endregion @@ -292,8 +274,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); } dualAllowedContentTypes.Value = chosenContentTypeIDs; } - - allowAtRoot.Checked = cType.AllowAtRoot; } private void SaveAllowedChildTypes() @@ -307,7 +287,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); int[] ids = new int[tmp.Count]; for (int i = 0; i < tmp.Count; i++) ids[i] = (int)tmp[i]; cType.AllowedChildContentTypeIDs = ids; - cType.AllowAtRoot = allowAtRoot.Checked; } #endregion diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs index 91480b9dcf..bc732a166a 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs @@ -183,24 +183,6 @@ namespace umbraco.controls { /// protected global::System.Web.UI.WebControls.TextBox txtAlias; - /// - /// pp_container control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_container; - - /// - /// isContainer control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox isContainer; - /// /// pp_icon control. /// @@ -273,24 +255,6 @@ namespace umbraco.controls { /// protected global::umbraco.uicontrols.Pane Pane5; - /// - /// pp_Root control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_Root; - - /// - /// allowAtRoot control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox allowAtRoot; - /// /// pp_allowedChildren control. /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs index 68427d341d..e39bef550f 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/content.ascx.cs @@ -4,7 +4,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using umbraco.cms.businesslogic.web; using umbraco.presentation.create; -using Content = umbraco.cms.businesslogic.Content; +using Content=umbraco.cms.businesslogic.Content; using umbraco.cms.helpers; using umbraco.BasePages; using umbraco.IO; @@ -37,7 +37,6 @@ namespace umbraco.cms.presentation.create.controls StringBuilder js = new StringBuilder(); foreach (DocumentType dt in DocumentType.GetAllAsList()) { - // if we're at root, we'll only allow root types string docDescription = "No description available..."; if (dt.Description != null && dt.Description != "") docDescription = dt.Description; @@ -45,7 +44,7 @@ namespace umbraco.cms.presentation.create.controls docDescription = docDescription.Replace("'", "\\'"); string docImage = (dt.Thumbnail != "") ? dt.Thumbnail : "../nada.gif"; - docImage = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/images/thumbnails/" + docImage; + docImage = IOHelper.ResolveUrl( SystemDirectories.Umbraco ) + "/images/thumbnails/" + docImage; ListItem li = new ListItem(); li.Text = dt.Text; @@ -54,30 +53,29 @@ namespace umbraco.cms.presentation.create.controls if (NodeId > 0) { foreach (int i in allowedIds) if (i == dt.Id) + { + nodeType.Items.Add(li); + js.Append("typeInfo[" + counter + "] = '

" + + docDescription + "

'\n"); + + if (!typeInited) { - nodeType.Items.Add(li); - js.Append("typeInfo[" + counter + "] = '

" + - docDescription + "

'\n"); - - if (!typeInited) - { - descr.Text = "

" + - docDescription + "

"; - typeInited = true; - - } - counter++; + descr.Text = "

" + + docDescription + "

"; + typeInited = true; + } + counter++; + } } - else if (dt.AllowAtRoot) - { + else { nodeType.Items.Add(li); js.Append("typeInfo[" + counter + "] = '

" + docDescription + "

'\n"); if (!typeInited) { descr.Text = "

" + - docDescription + "

"; + docDescription + "

'"; typeInited = true; } counter++; @@ -85,8 +83,7 @@ namespace umbraco.cms.presentation.create.controls } - if (nodeType.Items.Count == 0) - { + if (nodeType.Items.Count == 0) { sbmt.Enabled = false; } typeJs.Text = "\n "; @@ -130,9 +127,9 @@ namespace umbraco.cms.presentation.create.controls int.Parse(Request["nodeID"]), rename.Text); - BasePage.Current.ClientTools - .ChangeContentFrameUrl(returnUrl) - .CloseModalWindow(); + BasePage.Current.ClientTools + .ChangeContentFrameUrl(returnUrl) + .CloseModalWindow(); } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs index dc66e6f8b2..2ae91676a5 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/media.ascx.cs @@ -38,7 +38,7 @@ namespace umbraco.cms.presentation.create.controls { foreach (int i in allowedIds) if (i == dt.Id) nodeType.Items.Add(li); } - else if (dt.AllowAtRoot) + else nodeType.Items.Add(li); } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs index 4d1177433d..9b782673c3 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installedPackage.aspx.cs @@ -459,13 +459,6 @@ namespace umbraco.presentation.developer.packages DocumentType s = new DocumentType(nId); if (s != null) { - // check for master doctypes - if (s.IsMaster()) - { - foreach(var ct in s.GetChildTypes()) - ct.RemoveParentContentType(s.Id); - } - s.delete(); pack.Data.Documenttypes.Remove(nId.ToString()); diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 0a89941439..befaa03556 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics; using System.Threading; using System.Runtime.CompilerServices; using System.Linq; @@ -76,17 +75,14 @@ namespace umbraco.cms.businesslogic /// all of the properties that are initialized normally from the database. /// This is used for performance reasons. /// - internal ContentType(int id, string alias, string icon, string thumbnail, int? masterContentType, bool? isContainer) + internal ContentType(int id, string alias, string icon, string thumbnail, int? masterContentType) : base(id, true) { _alias = alias; _iconurl = icon; _thumbnail = thumbnail; if (masterContentType.HasValue) - MasterContentType = masterContentType.Value; - - if (isContainer.HasValue) - _isContainerContentType = isContainer.Value; + m_masterContentType = masterContentType.Value; } #endregion @@ -95,7 +91,7 @@ namespace umbraco.cms.businesslogic protected internal const string m_SQLOptimizedGetAll = @" SELECT id, createDate, trashed, parentId, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text, - allowAtRoot, isContainer, Alias,icon,thumbnail,description + masterContentType,Alias,icon,thumbnail,description FROM umbracoNode INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId WHERE nodeObjectType = @nodeObjectType"; @@ -168,24 +164,74 @@ namespace umbraco.cms.businesslogic return _propertyTypeCache[key]; } - // With 4.10 we can't do this via direct SQL as we have content type mixins + //Instead of going via API, run this query to find the control type + //by-passes a lot of queries just to determine if this is a true/false data type + + //This SQL returns a larger recordset than intended + //causing controlId to sometimes be null instead of correct + //because all properties for the type are returned + //side effect of changing inner join to left join when adding masterContentType + //string sql = "select " + + // "cmsDataType.controlId, masterContentType.alias as masterAlias " + + // "from " + + // "cmsContentType " + + // "inner join cmsPropertyType on (cmsContentType.nodeId = cmsPropertyType.contentTypeId) " + + // "left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) and cmsPropertyType.Alias = @propertyAlias " + + // "left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " + + // "where cmsContentType.alias = @contentTypeAlias"; + + //this SQL correctly returns a single row when the property exists, but still returns masterAlias if it doesn't + string sql = "select cmsDataType.controlId, masterContentType.alias as masterAlias " + + "from " + + "cmsContentType " + + "left join cmsPropertyType on (cmsContentType.nodeId = cmsPropertyType.contentTypeId and cmsPropertyType.Alias = @propertyAlias) " + + "left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) " + + "left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " + + "where " + + "cmsContentType.alias = @contentTypeAlias"; + + //Ensure that getdatatype doesn't throw an exception + //http://our.umbraco.org/forum/developers/razor/18085-Access-custom-node-properties-with-Razor + + //grab the controlid or test for parent Guid controlId = Guid.Empty; - ContentType ct = GetByAlias(contentTypeAlias); - PropertyType pt = ct.getPropertyType(propertyTypeAlias); - if (pt != null) + IRecordsReader reader = null; + try { - controlId = pt.DataTypeDefinition.DataType.Id; + reader = Application.SqlHelper.ExecuteReader(sql, + Application.SqlHelper.CreateParameter("@contentTypeAlias", contentTypeAlias), + Application.SqlHelper.CreateParameter("@propertyAlias", propertyTypeAlias) + ); + if (reader.Read()) + { + if (!reader.IsNull("controlId")) + controlId = reader.GetGuid("controlId"); + else if (!reader.IsNull("masterAlias") && !String.IsNullOrEmpty(reader.GetString("masterAlias"))) + { + controlId = GetDataType(reader.GetString("masterAlias"), propertyTypeAlias); + } + + } + } + catch (UmbracoException) + { + _propertyTypeCache.Add(key, controlId); + } + finally + { + if (reader != null) + { + reader.Close(); + } } - //add to cache (even if empty!) + //add to cache if (!_propertyTypeCache.ContainsKey(key)) { _propertyTypeCache.Add(key, controlId); } - return controlId; - } @@ -268,7 +314,7 @@ namespace umbraco.cms.businesslogic /// The Id of the Tab on which the PropertyType is placed public static int getTabIdFromPropertyType(PropertyType pt) { - object tmp = SqlHelper.ExecuteScalar("Select propertyTypeGroupId from cmsPropertyType where id = " + pt.Id.ToString()); + object tmp = SqlHelper.ExecuteScalar("Select tabId from cmsPropertyType where id = " + pt.Id.ToString()); if (tmp == DBNull.Value) return 0; else return int.Parse(tmp.ToString()); @@ -279,12 +325,11 @@ namespace umbraco.cms.businesslogic #region Private Members //private bool _optimizedMode = false; - private bool _allowAtRoot; private string _alias; private string _iconurl; private string _description; private string _thumbnail; - List m_masterContentTypes; + private int m_masterContentType = 0; private bool _isContainerContentType = false; private List m_AllowedChildContentTypeIDs = null; @@ -307,24 +352,12 @@ namespace umbraco.cms.businesslogic { _isContainerContentType = value; SqlHelper.ExecuteNonQuery( - "update cmsContentType set isContainer = @isContainer where nodeId = @id", - SqlHelper.CreateParameter("@isContainer", value), + "update cmsContentType set isContainerContentType = @isContainerContentType where nodeId = @id", + SqlHelper.CreateParameter("@isContainerContentType", value), SqlHelper.CreateParameter("@id", Id)); } } - public bool AllowAtRoot - { - get { return _allowAtRoot; } - set - { - _allowAtRoot = value; - SqlHelper.ExecuteNonQuery( - "update cmsContentType set allowAtRoot = @allowAtRoot where nodeId = @id", - SqlHelper.CreateParameter("@allowAtRoot", value), - SqlHelper.CreateParameter("@id", Id)); - } - } /// /// Gets or sets the description. /// @@ -469,15 +502,11 @@ namespace umbraco.cms.businesslogic } // Get Property Types from the master content type - if (MasterContentTypes.Count > 0) + if (MasterContentType != 0) { - foreach (var mct in MasterContentTypes) + foreach (PropertyType pt in ContentType.GetContentType(MasterContentType).PropertyTypes) { - List pts = ContentType.GetContentType(mct).PropertyTypes; - foreach (PropertyType pt in pts) - { - result.Add(pt); - } + result.Add(pt); } } return result; @@ -533,158 +562,28 @@ namespace umbraco.cms.businesslogic /// Gets or sets the Master Content Type for inheritance of tabs and properties. /// /// The ID of the Master Content Type - public List MasterContentTypes - { - get - { - if (m_masterContentTypes == null) - { - m_masterContentTypes = new List(); - using (IRecordsReader dr = - SqlHelper.ExecuteReader(@" - SELECT - parentContentTypeId - FROM - cmsContentType2ContentType - WHERE childContentTypeId = @id", SqlHelper.CreateParameter("@id", Id)) - ) - { - while (dr.Read()) - { - m_masterContentTypes.Add(dr.GetInt("parentContentTypeId")); - } - } - - - } - return m_masterContentTypes; - } - } - public int MasterContentType { get { - if (MasterContentTypes.Count > 0) - return MasterContentTypes[0]; - - return 0; + return m_masterContentType; } set { - if (value != MasterContentType) - { - //TODO: Add support for multiple masters - foreach (var mct in MasterContentTypes) - { - RemoveParentContentType(mct); - } - AddParentContentType(value); - } + m_masterContentType = value; + + SqlHelper.ExecuteNonQuery("update cmsContentType set masterContentType = @masterContentType where nodeId = @nodeId", + SqlHelper.CreateParameter("@masterContentType", value), + SqlHelper.CreateParameter("@nodeId", Id)); + + // Remove from cache + FlushFromCache(Id); } } - public void AddParentContentType(int parentContentTypeId) - { - if (MasterContentTypes.Contains(parentContentTypeId)) - { - // Should we throw an exception if you try to add something that already exist? - } - else - { - SqlHelper.ExecuteNonQuery( - "INSERT INTO [cmsContentType2ContentType] (parentContentTypeId, childContentTypeId) VALUES (@parentContentTypeId, @childContentTypeId)", - SqlHelper.CreateParameter("@parentContentTypeId", parentContentTypeId), - SqlHelper.CreateParameter("@childContentTypeId", Id)); - MasterContentTypes.Add(parentContentTypeId); - } - } - - public bool IsMaster() - { - return - SqlHelper.ExecuteScalar( - "select count(*) from cmsContentType2ContentType where parentContentTypeId = @parentContentTypeId", - SqlHelper.CreateParameter("@parentContentTypeId", this.Id)) > 0; - } - - public IEnumerable GetChildTypes() - { - var cts = new List(); - using (IRecordsReader dr = - SqlHelper.ExecuteReader(@" - SELECT - childContentTypeId - FROM - cmsContentType2ContentType - WHERE parentContentTypeId = @parentContentTypeId", - SqlHelper.CreateParameter("@parentContentTypeId", Id)) - ) - { - while (dr.Read()) - { - cts.Add(GetContentType(dr.GetInt("childContentTypeId"))); - } - } - - return cts; - } - - public void RemoveParentContentType(int parentContentTypeId) - { - if (!MasterContentTypes.Contains(parentContentTypeId)) - { - // Should we throw an exception if you're trying to remove something that doesn't exist? - } - else - { - - // Clean up property data (when we remove a reference we also need to remove all data relating to the doc type! - // So that would be all propertyData that uses a propertyType from the content type with 'parentContentTypeId' and - // has a nodetype of this id - var contentTypeToRemove = new ContentType(parentContentTypeId); - - RemoveMasterPropertyTypeData(contentTypeToRemove, this); - - SqlHelper.ExecuteNonQuery( - "DELETE FROM [cmsContentType2ContentType] WHERE parentContentTypeId = @parentContentTypeId AND childContentTypeId = @childContentTypeId", - SqlHelper.CreateParameter("@parentContentTypeId", parentContentTypeId), - SqlHelper.CreateParameter("@childContentTypeId", Id)); - MasterContentTypes.Remove(parentContentTypeId); - } - } - - private void RemoveMasterPropertyTypeData(ContentType contentTypeToRemove, ContentType currentContentType) - { - foreach (var pt in contentTypeToRemove.PropertyTypes) - { - if (pt.ContentTypeId == contentTypeToRemove.Id) - { - // before we can remove a parent content type we need to remove all data that - // relates to property types - SqlHelper.ExecuteNonQuery( - @"delete cmsPropertyData from cmsPropertyData - inner join cmsContent on cmsContent.nodeId = cmsPropertyData.contentNodeId - where cmsPropertyData.propertyTypeId = @propertyType - and contentType = @contentType", - SqlHelper.CreateParameter("@contentType", currentContentType.Id), - SqlHelper.CreateParameter("@propertyType", pt.Id)); - } - } - // remove sub data too - foreach(var ct in currentContentType.GetChildTypes()) - RemoveMasterPropertyTypeData(contentTypeToRemove, ct); - } - - public IEnumerable PropertyTypeGroups - { - get { return PropertyTypeGroup.GetPropertyTypeGroupsFromContentType(Id); } - } - /// /// Retrieve a list of all Tabs on the current ContentType /// - [Obsolete("Use PropertyTypeGroup methods instead", false)] public TabI[] getVirtualTabs { get @@ -698,7 +597,6 @@ namespace umbraco.cms.businesslogic /// /// Clears the locally loaded tabs which forces them to be reloaded next time they requested /// - [Obsolete("Use PropertyTypeGroup methods instead", false)] public void ClearVirtualTabs() { // zb-00040 #29889 : clear the right cache! t.contentType is the ctype which _defines_ the tab, not the current one. @@ -833,7 +731,6 @@ namespace umbraco.cms.businesslogic /// /// The PropertyType /// The Id of the Tab - [Obsolete("Use PropertyTypeGroup methods instead", false)] public void SetTabOnPropertyType(PropertyType pt, int TabId) { // This is essentially just a wrapper for the property @@ -846,7 +743,6 @@ namespace umbraco.cms.businesslogic /// Removing a PropertyType from the associated Tab /// /// The PropertyType which should be freed from its tab - [Obsolete("Use PropertyTypeGroup methods instead", false)] public void removePropertyTypeFromTab(PropertyType pt) { pt.TabId = 0; //this will set to null in the database. @@ -860,29 +756,43 @@ namespace umbraco.cms.businesslogic /// Returns the Id of the new Tab /// [MethodImpl(MethodImplOptions.Synchronized)] - [Obsolete("Use PropertyTypeGroup methods instead", false)] public int AddVirtualTab(string Caption) { // Get tab count + int tabCount = SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM cmsTab WHERE contenttypeNodeId = @nodeId", + SqlHelper.CreateParameter("@nodeId", Id)); + // The method is synchronized - PropertyTypeGroup ptg = new PropertyTypeGroup(0, Id, Caption); - ptg.Save(); + SqlHelper.ExecuteNonQuery("INSERT INTO cmsTab (contenttypeNodeId,text,sortorder) VALUES (@nodeId,@text,@sortorder)", + SqlHelper.CreateParameter("@nodeId", Id), + SqlHelper.CreateParameter("@text", Caption), + SqlHelper.CreateParameter("@sortorder", tabCount + 1)); // Remove from cache FlushFromCache(Id); - return ptg.Id; + return SqlHelper.ExecuteScalar("SELECT MAX(id) FROM cmsTab"); } /// /// Releases all PropertyTypes on tab (this does not delete the PropertyTypes) and then Deletes the Tab /// /// The Id of the Tab to be deleted. - [Obsolete("Use PropertyTypeGroup methods instead", false)] public void DeleteVirtualTab(int id) { - PropertyTypeGroup.GetPropertyTypeGroup(id).Delete(); + //set each property on the tab to have a tab id of zero + // zb-00036 #29889 : fix property types getter + this.getVirtualTabs.ToList() + .Where(x => x.Id == id) + .Single() + .GetAllPropertyTypes() + .ForEach(x => + { + x.TabId = 0; + }); + + SqlHelper.ExecuteNonQuery("delete from cmsTab where id =" + id); // Remove from cache FlushFromCache(Id); @@ -893,12 +803,11 @@ namespace umbraco.cms.businesslogic /// /// The Id of the Tab to be updated /// The new Caption - [Obsolete("Use PropertyTypeGroup methods instead", false)] - public void SetTabName(int tabId, string caption) + public void SetTabName(int tabId, string Caption) { - var ptg = PropertyTypeGroup.GetPropertyTypeGroup(tabId); - ptg.Name = caption; - ptg.Save(); + SqlHelper.ExecuteNonQuery("Update cmsTab set text = @text where id = @id", + SqlHelper.CreateParameter("@text", Caption), + SqlHelper.CreateParameter("@id", tabId)); // Remove from cache FlushFromCache(Id); @@ -909,12 +818,10 @@ namespace umbraco.cms.businesslogic /// /// The Id of the Tab to be updated /// The new order number - [Obsolete("Use PropertyTypeGroup methods instead", false)] public void SetTabSortOrder(int tabId, int sortOrder) { - var ptg = PropertyTypeGroup.GetPropertyTypeGroup(tabId); - ptg.SortOrder = sortOrder; - ptg.Save(); + SqlHelper.ExecuteNonQuery( + "Update cmsTab set sortOrder = " + sortOrder + " where id = " + tabId); // Remove from cache FlushFromCache(Id); @@ -969,11 +876,11 @@ namespace umbraco.cms.businesslogic } // delete all tabs - foreach (PropertyTypeGroup ptg in PropertyTypeGroups) + foreach (Tab t in getVirtualTabs.ToList()) { - if (ptg.ContentTypeId == this.Id) + if (t.ContentType == this.Id) { - ptg.Delete(); + t.Delete(); } } @@ -997,8 +904,8 @@ namespace umbraco.cms.businesslogic { _alias = dr.GetString("Alias"); _iconurl = dr.GetString("icon"); - _isContainerContentType = dr.GetBoolean("isContainer"); - _allowAtRoot = dr.GetBoolean("allowAtRoot"); + if (!dr.IsNull("masterContentType")) + m_masterContentType = dr.GetInt("masterContentType"); if (!dr.IsNull("thumbnail")) _thumbnail = dr.GetString("thumbnail"); @@ -1013,9 +920,8 @@ namespace umbraco.cms.businesslogic { base.setupNode(); - // TODO: Load master content types using (IRecordsReader dr = - SqlHelper.ExecuteReader("Select allowAtRoot, isContainer, Alias,icon,thumbnail,description from cmsContentType where nodeid=" + Id) + SqlHelper.ExecuteReader("Select masterContentType,Alias,icon,thumbnail,description from cmsContentType where nodeid=" + Id) ) { if (dr.Read()) @@ -1053,7 +959,6 @@ namespace umbraco.cms.businesslogic RemoveFromDataTypeCache(ct.Alias); // clear anything that uses this as master content type - //TODO: Update to load all content types if (ct.nodeObjectType == DocumentType._objectType) { List cacheToFlush = DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == id); @@ -1092,7 +997,6 @@ namespace umbraco.cms.businesslogic /// /// Checks if we've loaded the virtual tabs into memory and if not gets them from the databse. /// - [Obsolete("Use PropertyTypeGroup methods instead", false)] private void EnsureVirtualTabs() { // This class can be cached and potentially shared between multiple threads. @@ -1112,37 +1016,44 @@ namespace umbraco.cms.businesslogic } } } - + + /// /// Loads the tabs into memory from the database and stores them in a local list for retreival /// - [Obsolete("Use PropertyTypeGroup methods instead", false)] private void InitializeVirtualTabs() { - m_VirtualTabs = new List(); - foreach (PropertyTypeGroup ptg in PropertyTypeGroups.Where(x => x.ParentId == 0 && x.ContentTypeId == this.Id)) - m_VirtualTabs.Add(new Tab(ptg.Id, ptg.Name, ptg.SortOrder, this)); + // While we are initialising, we should not use the class-scoped list, as it may be used by other threads + var temporaryList = new List(); + using (IRecordsReader dr = SqlHelper.ExecuteReader( + string.Format( + "Select Id,text,sortOrder from cmsTab where contenttypeNodeId = {0} order by sortOrder", + Id))) + { + while (dr.Read()) + { + temporaryList.Add(new Tab(dr.GetInt("id"), dr.GetString("text"), dr.GetInt("sortOrder"), this)); + } + } // Master Content Type - if (MasterContentTypes.Count > 0) + if (MasterContentType != 0) { - foreach (var mct in MasterContentTypes) - foreach (TabI t in ContentType.GetContentType(mct).getVirtualTabs.ToList()) - { - m_VirtualTabs.Add(t); - } + temporaryList.AddRange(GetContentType(MasterContentType).getVirtualTabs.ToList()); } // sort all tabs - m_VirtualTabs.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder)); + temporaryList.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder)); + + // now that we aren't going to modify the list, we can set it to the class-scoped variable. + m_VirtualTabs = temporaryList; } private void populateMasterContentTypes(PropertyType pt, int docTypeId) { foreach (web.DocumentType docType in web.DocumentType.GetAllAsList()) { - //TODO: Check for multiple references (mixins) not causing endless loops! - if (docType.MasterContentTypes.Contains(docTypeId)) + if (docType.MasterContentType == docTypeId) { populatePropertyData(pt, docType.Id); populateMasterContentTypes(pt, docType.Id); @@ -1236,7 +1147,6 @@ namespace umbraco.cms.businesslogic /// A tab is merely a way to organize data on a ContentType to make it more /// human friendly /// - [Obsolete("Please use PropertyTypes instead", false)] public class Tab : TabI { private ContentType _contenttype; @@ -1261,11 +1171,16 @@ namespace umbraco.cms.businesslogic public static Tab GetTab(int id) { Tab tab = null; - // Tabs have been replaced with PropertyTypeGroups, so we use the new api to provide legacy support - PropertyTypeGroup ptg = PropertyTypeGroup.GetPropertyTypeGroup(id); - if (ptg != null) + using (IRecordsReader dr = SqlHelper.ExecuteReader( + string.Format( + "Select Id, text, contenttypeNodeId, sortOrder from cmsTab where Id = {0} order by sortOrder", + id))) { - tab = new Tab(id, ptg.Name, ptg.SortOrder, new ContentType(ptg.ContentTypeId)); + if (dr.Read()) + { + tab = new Tab(id, dr.GetString("text"), dr.GetInt("sortOrder"), new ContentType(dr.GetInt("contenttypeNodeId"))); + } + dr.Close(); } return tab; @@ -1283,21 +1198,53 @@ namespace umbraco.cms.businesslogic // Also this is public now because we removed the PropertyTypes property (not making sense). public PropertyType[] GetPropertyTypes(int contentTypeId, bool includeInheritedProperties) { + // zb-00040 #29889 : fix cache key issues! + // now maintaining a cache of local properties per contentTypeId, then merging when required + // another way would be to maintain a cache of *all* properties, then filter when required + // however it makes it more difficult to figure out what to clear (ie needs to find all children...) + + var tmp = new List(); + var ctypes = new List(); - // NH, temp fix for 4.9 to use the new PropertyTypeGroup API - var pts = PropertyTypeGroup.GetPropertyTypeGroup(this.Id).GetPropertyTypes(); if (includeInheritedProperties) { - // we need to - cms.businesslogic.ContentType ct = cms.businesslogic.ContentType.GetContentType(contentTypeId); - return - pts.Where( - x => - ct.MasterContentTypes.Contains( - x.ContentTypeId) || x.ContentTypeId == contentTypeId).ToArray(); + // start from contentTypeId and list all ctypes, going up + int c = contentTypeId; + while (c != 0) + { + ctypes.Add(c); + c = umbraco.cms.businesslogic.ContentType.GetContentType(c).MasterContentType; + } + ctypes.Reverse(); // order from the top + } + else + { + // just that one + ctypes.Add(contentTypeId); } - return pts.Where(x => x.ContentTypeId == contentTypeId).ToArray(); + foreach (var ctype in ctypes) + { + var ptypes = Cache.GetCacheItem>( + generateCacheKey(Id, ctype), propertyTypesCacheSyncLock, TimeSpan.FromMinutes(10), + delegate + { + var tmp1 = new List(); + + using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format( + @"select id from cmsPropertyType where tabId = {0} and contentTypeId = {1} + order by sortOrder", _id, ctype))) + { + while (dr.Read()) + tmp1.Add(PropertyType.GetPropertyType(dr.GetInt("id"))); + } + return tmp1; + }); + + tmp.AddRange(ptypes); + } + + return tmp.ToArray(); } // zb-00036 #29889 : yet we may want to be able to get *all* property types @@ -1306,7 +1253,7 @@ namespace umbraco.cms.businesslogic var tmp = new List(); using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format( - @"select id from cmsPropertyType where propertyTypeGroupId = {0}", _id))) + @"select id from cmsPropertyType where tabId = {0}", _id))) { while (dr.Read()) tmp.Add(PropertyType.GetPropertyType(dr.GetInt("id"))); @@ -1346,9 +1293,9 @@ namespace umbraco.cms.businesslogic /// public void Delete() { - SqlHelper.ExecuteNonQuery("update cmsPropertyType set propertyTypeGroupId = NULL where propertyTypeGroupId = @id", + SqlHelper.ExecuteNonQuery("update cmsPropertyType set tabId = NULL where tabid = @id", SqlHelper.CreateParameter("@id", Id)); - SqlHelper.ExecuteNonQuery("delete from cmsPropertyTypeGroup where id = @id", + SqlHelper.ExecuteNonQuery("delete from cmsTab where id = @id", SqlHelper.CreateParameter("@id", Id)); } @@ -1361,7 +1308,7 @@ namespace umbraco.cms.businesslogic { try { - string tempCaption = SqlHelper.ExecuteScalar("Select text from cmsPropertyTypeGroup where id = " + id.ToString()); + string tempCaption = SqlHelper.ExecuteScalar("Select text from cmsTab where id = " + id.ToString()); if (!tempCaption.StartsWith("#")) return tempCaption; else @@ -1396,20 +1343,19 @@ namespace umbraco.cms.businesslogic { if (!_sortOrder.HasValue) { - _sortOrder = SqlHelper.ExecuteScalar("select sortOrder from cmsPropertyTypeGroup where id = " + _id); + _sortOrder = SqlHelper.ExecuteScalar("select sortOrder from cmsTab where id = " + _id); } return _sortOrder.Value; } set { - SqlHelper.ExecuteNonQuery("update cmsPropertyTypeGroup set sortOrder = " + value + " where id =" + _id); + SqlHelper.ExecuteNonQuery("update cmsTab set sortOrder = " + value + " where id =" + _id); } } /// /// Moves the Tab up /// - [Obsolete("Please use GetPropertyTypes() instead", false)] public void MoveUp() { FixTabOrder(); @@ -1432,7 +1378,6 @@ namespace umbraco.cms.businesslogic /// /// Moves the Tab down /// - [Obsolete("Please use GetPropertyTypes() instead", false)] public void MoveDown() { FixTabOrder(); diff --git a/src/umbraco.cms/businesslogic/media/Media.cs b/src/umbraco.cms/businesslogic/media/Media.cs index df6b02fde5..a36cd99458 100644 --- a/src/umbraco.cms/businesslogic/media/Media.cs +++ b/src/umbraco.cms/businesslogic/media/Media.cs @@ -22,15 +22,15 @@ namespace umbraco.cms.businesslogic.media #region Constants and static members private const string m_SQLOptimizedMany = @" select - count(children.id) as children, cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text, - cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId as contentTypeId + count(children.id) as children, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text, + cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId from umbracoNode left join umbracoNode children on children.parentId = umbracoNode.id inner join cmsContent on cmsContent.nodeId = umbracoNode.id inner join cmsContentType on cmsContentType.nodeId = cmsContent.contentType where umbracoNode.nodeObjectType = @nodeObjectType AND {0} - group by cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text, - cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId + group by umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text, + cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId order by {1}"; #endregion @@ -270,6 +270,8 @@ namespace umbraco.cms.businesslogic.media if (dr.GetInt("children") > 0) _hc = true; int? masterContentType = null; + if (!dr.IsNull("masterContentType")) + masterContentType = dr.GetInt("masterContentType"); SetupMediaForTree(dr.GetGuid("uniqueId") , dr.GetShort("level") , dr.GetInt("parentId") @@ -283,18 +285,17 @@ namespace umbraco.cms.businesslogic.media , dr.GetString("thumbnail") , dr.GetString("description") , masterContentType - , dr.GetInt("contentTypeId") - , dr.GetBoolean("isContainer")); + , dr.GetInt("contentTypeId")); } #endregion #region Private methods private void SetupMediaForTree(Guid uniqueId, int level, int parentId, int user, string path, string text, DateTime createDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb, - string contentTypeDesc, int? masterContentType, int contentTypeId, bool isContainer) + string contentTypeDesc, int? masterContentType, int contentTypeId) { SetupNodeForTree(uniqueId, _objectType, level, parentId, user, path, text, createDate, hasChildren); - ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType, isContainer); + ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType); ContentTypeIcon = icon; } diff --git a/src/umbraco.cms/businesslogic/propertytype/PropertyTypeGroup.cs b/src/umbraco.cms/businesslogic/propertytype/PropertyTypeGroup.cs deleted file mode 100644 index ded02e8abc..0000000000 --- a/src/umbraco.cms/businesslogic/propertytype/PropertyTypeGroup.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using umbraco.BusinessLogic; -using umbraco.cms.businesslogic.property; -using umbraco.DataLayer; - -namespace umbraco.cms.businesslogic.propertytype -{ - public class PropertyTypeGroup - { - public int Id { get; set; } - public int ParentId { get; set; } - public int ContentTypeId { get; set; } - public string Name { get; set; } - public int SortOrder { get; set; } - - public PropertyTypeGroup() - { - - } - - public PropertyTypeGroup(int parentId, int contentTypeId, string name, int sortOrder) - { - ParentId = parentId; - ContentTypeId = contentTypeId; - Name = name; - SortOrder = sortOrder; - } - - public PropertyTypeGroup(int parentId, int contentTypeId, string name) - { - ParentId = parentId; - ContentTypeId = contentTypeId; - Name = name; - SortOrder = -1; // we set this to -1 so in the save method we can get the current highest sortorder in case it's not sat after init (ie. if you want to force a sortOrder) - } - - public IEnumerable GetPropertyTypes(List contentTypeIds) - { - return PropertyType.GetPropertyTypesByGroup(Id, contentTypeIds); - } - - public IEnumerable GetPropertyTypes() - { - return PropertyType.GetPropertyTypesByGroup(Id); - } - - //TODO: Verify support for master doctypes / mixins! - public IEnumerable GetPropertyTypeGroups() - { - var ptgs = new List(); - using (IRecordsReader dr = - SqlHelper.ExecuteReader(@" - SELECT - id - FROM - cmsPropertyTypeGroup - WHERE parentGroupId = @id", SqlHelper.CreateParameter("@id", Id)) - ) - { - while (dr.Read()) - { - ptgs.Add(GetPropertyTypeGroup(dr.GetInt("id"))); - } - } - - return ptgs; - } - - public void Save() - { - if (Id != 0) - { - SqlHelper.ExecuteNonQuery( - @" - UPDATE - cmsPropertyTypeGroup - SET - parentGroupId = @parentGroupId, - contenttypeNodeId = @contentTypeId, - sortOrder = @sortOrder, - text = @name - WHERE - id = @id - ", - SqlHelper.CreateParameter("@id", Id), - SqlHelper.CreateParameter("@parentGroupId", ConvertParentId(ParentId)), - SqlHelper.CreateParameter("@contentTypeId", ContentTypeId), - SqlHelper.CreateParameter("@sortOrder", SortOrder), - SqlHelper.CreateParameter("@name", Name) - ); - } - else - { - if (SortOrder == -1) - SortOrder = SqlHelper.ExecuteScalar("select count(*) from cmsPropertyTypeGroup where COALESCE(parentGroupId, 0) = 0 and contenttypeNodeId = @nodeId", - SqlHelper.CreateParameter("@nodeId", ContentTypeId)) + 1; - - SqlHelper.ExecuteNonQuery( - @" - INSERT INTO - cmsPropertyTypeGroup - (parentGroupId, contenttypeNodeId, sortOrder, text) - VALUES - (@parentGroupId, @contentTypeId, @sortOrder, @name) - ", - SqlHelper.CreateParameter("@parentGroupId", ConvertParentId(ParentId)), - SqlHelper.CreateParameter("@contentTypeId", ContentTypeId), - SqlHelper.CreateParameter("@sortOrder", SortOrder), - SqlHelper.CreateParameter("@name", Name) - ); - Id = SqlHelper.ExecuteScalar("SELECT MAX(id) FROM [cmsPropertyTypeGroup]"); - - } - } - - public void Delete() - { - - // update all PropertyTypes using this group - foreach (var pt in GetPropertyTypes()) - { - pt.PropertyTypeGroup = 0; - pt.Save(); - } - - foreach (PropertyTypeGroup ptg in GetPropertyTypeGroups()) - ptg.Delete(); - - SqlHelper.ExecuteNonQuery("DELETE FROM cmsPropertyTypeGroup WHERE id = @id", - SqlHelper.CreateParameter("@id", Id)); - } - - internal void Load() - { - using (IRecordsReader dr = - SqlHelper.ExecuteReader(@" - SELECT - parentGroupId, contenttypeNodeId, sortOrder, text - FROM - cmsPropertyTypeGroup - WHERE id = @id", SqlHelper.CreateParameter("@id", Id)) - ) - { - if (dr.Read()) - { - // if no parent, the value should just be null. The GetInt helper method returns -1 if value is null so we need to check - ParentId = dr.GetInt("parentGroupId") != -1 ? dr.GetInt("parentGroupId") : 0; - SortOrder = dr.GetInt("sortOrder"); - ContentTypeId = dr.GetInt("contenttypeNodeId"); - Name = dr.GetString("text"); - } - } - - } - - public static PropertyTypeGroup GetPropertyTypeGroup(int id) - { - PropertyTypeGroup ptg = new PropertyTypeGroup(); - ptg.Id = id; - ptg.Load(); - return ptg; - } - - public static IEnumerable GetPropertyTypeGroupsFromContentType(int contentTypeId) - { - var ptgs = new List(); - using (IRecordsReader dr = - SqlHelper.ExecuteReader(@" - SELECT - id - FROM - cmsPropertyTypeGroup - WHERE contenttypeNodeId = @contentTypeId", SqlHelper.CreateParameter("@contentTypeId", contentTypeId)) - ) - { - while (dr.Read()) - { - ptgs.Add(GetPropertyTypeGroup(dr.GetInt("id"))); - } - } - - return ptgs; - } - - private object ConvertParentId(int parentId) - { - if (parentId == 0) - return DBNull.Value; - - return parentId; - } - - - /// - /// Gets the SQL helper. - /// - /// The SQL helper. - protected static ISqlHelper SqlHelper - { - get { return Application.SqlHelper; } - } - - - - } -} diff --git a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs index 8d3fcd09c7..cc82c27db0 100644 --- a/src/umbraco.cms/businesslogic/propertytype/propertytype.cs +++ b/src/umbraco.cms/businesslogic/propertytype/propertytype.cs @@ -35,7 +35,6 @@ namespace umbraco.cms.businesslogic.propertytype private string _name; private int _sortOrder; private int _tabId; - private int _propertyTypeGroup; private string _validationRegExp = ""; #endregion @@ -50,19 +49,15 @@ namespace umbraco.cms.businesslogic.propertytype public PropertyType(int id) { using (IRecordsReader dr = SqlHelper.ExecuteReader( - "Select mandatory, DataTypeId, propertyTypeGroupId, ContentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id", + "Select mandatory, DataTypeId, tabId, ContentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id", SqlHelper.CreateParameter("@id", id))) { if (!dr.Read()) throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!"); _mandatory = dr.GetBoolean("mandatory"); _id = id; - if (!dr.IsNull("propertyTypeGroupId")) - { - _propertyTypeGroup = dr.GetInt("propertyTypeGroupId"); - //TODO: Remove after refactoring! - _tabId = _propertyTypeGroup; - } + if (!dr.IsNull("tabId")) + _tabId = dr.GetInt("tabId"); _sortOrder = dr.GetInt("sortOrder"); _alias = dr.GetString("alias"); _name = dr.GetString("Name"); @@ -101,33 +96,22 @@ namespace umbraco.cms.businesslogic.propertytype /// /// Setting the tab id to a negative value will actually set the value to NULL in the database /// - [Obsolete("Use the new PropertyTypeGroup parameter", false)] public int TabId { get { return _tabId; } set { _tabId = value; - PropertyTypeGroup = value; InvalidateCache(); - } - } - - public int PropertyTypeGroup - { - get { return _propertyTypeGroup; } - set - { - _propertyTypeGroup = value; - - object dbPropertyTypeGroup = value; + object tabId = value; if (value < 1) { - dbPropertyTypeGroup = DBNull.Value; + tabId = DBNull.Value; } - SqlHelper.ExecuteNonQuery("Update cmsPropertyType set propertyTypeGroupId = @propertyTypeGroupId where id = @id", - SqlHelper.CreateParameter("@propertyTypeGroupId", dbPropertyTypeGroup), - SqlHelper.CreateParameter("@id", Id)); + + SqlHelper.ExecuteNonQuery("Update cmsPropertyType set tabId = @tabId where id = @id", + SqlHelper.CreateParameter("@tabId", tabId), + SqlHelper.CreateParameter("@id", Id)); } } @@ -311,48 +295,20 @@ namespace umbraco.cms.businesslogic.propertytype public static PropertyType[] GetAll() { - var result = GetPropertyTypes(); + var result = new List(); + using (IRecordsReader dr = + SqlHelper.ExecuteReader("select id, Name from cmsPropertyType order by Name")) + { + while (dr.Read()) + { + PropertyType pt = GetPropertyType(dr.GetInt("id")); + if (pt != null) + result.Add(pt); + } + } return result.ToArray(); } - public static IEnumerable GetPropertyTypes() - { - var result = new List(); - using (IRecordsReader dr = - SqlHelper.ExecuteReader("select id from cmsPropertyType order by Name")) - { - while (dr.Read()) - { - PropertyType pt = GetPropertyType(dr.GetInt("id")); - if (pt != null) - result.Add(pt); - } - } - return result; - } - - public static IEnumerable GetPropertyTypesByGroup(int groupId, List contentTypeIds) - { - return GetPropertyTypesByGroup(groupId).Where(x => contentTypeIds.Contains(x.ContentTypeId)); - } - - public static IEnumerable GetPropertyTypesByGroup(int groupId) - { - var result = new List(); - using (IRecordsReader dr = - SqlHelper.ExecuteReader("SELECT id FROM cmsPropertyType WHERE propertyTypeGroupId = @groupId order by SortOrder", - SqlHelper.CreateParameter("@groupId", groupId))) - { - while (dr.Read()) - { - PropertyType pt = GetPropertyType(dr.GetInt("id")); - if (pt != null) - result.Add(pt); - } - } - return result; - } - /// /// Returns all property types based on the data type definition /// @@ -382,11 +338,11 @@ namespace umbraco.cms.businesslogic.propertytype FlushCache(); // clean all properties on inherited document types (if this propertytype is removed from a master) - CleanPropertiesOnDeletion(_contenttypeid); + cleanPropertiesOnDeletion(_contenttypeid); // DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == _contenttypeid).ForEach(dt => cleanPropertiesOnDeletion(dt.Id)); // Delete all properties of propertytype - CleanPropertiesOnDeletion(_contenttypeid); + cleanPropertiesOnDeletion(_contenttypeid); // Delete PropertyType .. SqlHelper.ExecuteNonQuery("Delete from cmsPropertyType where id = " + Id); @@ -409,12 +365,11 @@ namespace umbraco.cms.businesslogic.propertytype } } - private void CleanPropertiesOnDeletion(int contentTypeId) + private void cleanPropertiesOnDeletion(int contentTypeId) { // first delete from all master document types - //TODO: Verify no endless loops with mixins - DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentTypes.Contains(contentTypeId)).ForEach( - dt => CleanPropertiesOnDeletion(dt.Id)); + DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == contentTypeId).ForEach( + dt => cleanPropertiesOnDeletion(dt.Id)); // then remove from the current doc type Content[] objs = Content.getContentOfContentType(new ContentType(contentTypeId)); @@ -466,9 +421,9 @@ namespace umbraco.cms.businesslogic.propertytype Cache.ClearCacheItem("ContentType_PropertyTypes_Content:" + _contenttypeid); // clear cache in tab - // zb-00040 #29889 : clear the right cache! t.ContentType is the ctype which _defines_ the tab, not the current one. - // foreach (ContentType.TabI t in new ContentType(ContentTypeId).getVirtualTabs) - // ContentType.FlushTabCache(t.Id, ContentTypeId); + // zb-00040 #29889 : clear the right cache! t.ContentType is the ctype which _defines_ the tab, not the current one. + foreach (ContentType.TabI t in new ContentType(ContentTypeId).getVirtualTabs) + ContentType.FlushTabCache(t.Id, ContentTypeId); } public static PropertyType GetPropertyType(int id) diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index 2b3355e0b7..c8ad8a37cb 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -94,6 +94,9 @@ namespace umbraco.cms.businesslogic.web bool _hc = false; if (dr.GetInt("children") > 0) _hc = true; + int? masterContentType = null; + if (!dr.IsNull("masterContentType")) + masterContentType = dr.GetInt("masterContentType"); SetupDocumentForTree(dr.GetGuid("uniqueId") , dr.GetShort("level") , dr.GetInt("parentId") @@ -110,10 +113,9 @@ namespace umbraco.cms.businesslogic.web , dr.GetString("alias") , dr.GetString("thumbnail") , dr.GetString("description") - , null + , masterContentType , dr.GetInt("contentTypeId") , dr.GetInt("templateId") - , dr.GetBoolean("isContainer") ); // initialize content object @@ -151,11 +153,10 @@ namespace umbraco.cms.businesslogic.web Select CASE WHEN (childrenTable.total>0) THEN childrenTable.total ELSE 0 END as Children, CASE WHEN (publishedTable.publishedTotal>0) THEN publishedTable.publishedTotal ELSE 0 END as Published, - cmsContentType.isContainer, - cmsContentVersion.VersionId, + cmsContentVersion.VersionId, cmsContentVersion.versionDate, contentTypeNode.uniqueId as ContentTypeGuid, - cmsContent.ContentType, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId as contentTypeId, + cmsContent.ContentType, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId, published, documentUser, coalesce(templateId, cmsDocumentType.templateNodeId) as templateId, cmsDocument.text as DocumentText, releaseDate, expireDate, updateDate, umbracoNode.createDate, umbracoNode.trashed, umbracoNode.parentId, umbracoNode.nodeObjectType, umbracoNode.nodeUser, umbracoNode.level, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.uniqueId, umbracoNode.text from @@ -181,11 +182,11 @@ namespace umbraco.cms.businesslogic.web // inner join (select contentId, max(versionDate) as versionDate from cmsContentVersion group by contentId) temp // on cmsContentVersion.contentId = temp.contentId and cmsContentVersion.versionDate = temp.versionDate private const string m_SQLOptimizedMany = @" - select count(children.id) as children, cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, + select count(children.id) as children, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, cmsDocument.documentUser, coalesce(cmsDocument.templateId, cmsDocumentType.templateNodeId) as templateId, umbracoNode.path, umbracoNode.sortOrder, coalesce(publishCheck.published,0) as isPublished, umbracoNode.createDate, cmsDocument.text, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, cmsContentType.icon, cmsContentType.alias, - cmsContentType.thumbnail, cmsContentType.description, cmsContentType.nodeId as contentTypeId, + cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId, umbracoNode.nodeUser from umbracoNode left join umbracoNode children on children.parentId = umbracoNode.id @@ -197,11 +198,11 @@ namespace umbraco.cms.businesslogic.web left join cmsDocumentType on cmsDocumentType.contentTypeNodeId = cmsContent.contentType and cmsDocumentType.IsDefault = 1 where umbracoNode.nodeObjectType = @nodeObjectType AND cmsDocument.newest = 1 AND {0} group by - cmsContentType.isContainer, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, cmsDocument.documentUser, + umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, cmsDocument.documentUser, cmsDocument.templateId, cmsDocumentType.templateNodeId, umbracoNode.path, umbracoNode.sortOrder, coalesce(publishCheck.published,0), umbracoNode.createDate, cmsDocument.text, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, - cmsContentType.nodeId, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, umbracoNode.nodeUser + cmsContentType.masterContentType, cmsContentType.nodeId, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, umbracoNode.nodeUser order by {1} "; @@ -995,10 +996,10 @@ namespace umbraco.cms.businesslogic.web } _published = true; - DateTime versionDate = DateTime.Now; string tempVersion = Version.ToString(); + DateTime versionDate = DateTime.Now; Guid newVersion = createNewVersion(versionDate); - + Log.Add(LogTypes.Publish, u, Id, ""); //PPH make sure that there is only 1 newest node, this is important in regard to schedueled publishing... @@ -1068,7 +1069,7 @@ namespace umbraco.cms.businesslogic.web { DateTime versionDate = DateTime.Now; Guid newVersion = createNewVersion(versionDate); - + if (_template != 0) { SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, updateDate, Text, TemplateId) values (" + @@ -1085,7 +1086,7 @@ namespace umbraco.cms.businesslogic.web Id + ", 0, " + u.Id + ", @versionId, @text )", SqlHelper.CreateParameter("@versionId", newVersion), - SqlHelper.CreateParameter("@updateDate", versionDate), + SqlHelper.CreateParameter("@updateDate", versionDate), SqlHelper.CreateParameter("@text", Text)); } @@ -1681,26 +1682,30 @@ namespace umbraco.cms.businesslogic.web if (dr.GetInt("children") > 0) _hc = true; + int? masterContentType = null; + + if (!dr.IsNull("masterContentType")) + masterContentType = dr.GetInt("masterContentType"); + SetupDocumentForTree(dr.GetGuid("uniqueId") - , dr.GetShort("level") - , dr.GetInt("parentId") - , dr.GetInt("nodeUser") - , dr.GetInt("documentUser") - , (dr.GetInt("isPublished") == 1) - , dr.GetString("path") - , dr.GetString("text") - , dr.GetDateTime("createDate") - , dr.GetDateTime("updateDate") - , dr.GetDateTime("versionDate") - , dr.GetString("icon") - , _hc - , dr.GetString("alias") - , dr.GetString("thumbnail") - , dr.GetString("description") - , null - , dr.GetInt("contentTypeId") - , dr.GetInt("templateId") - , dr.GetBoolean("isContainer")); + , dr.GetShort("level") + , dr.GetInt("parentId") + , dr.GetInt("nodeUser") + , dr.GetInt("documentUser") + , (dr.GetInt("isPublished") == 1) + , dr.GetString("path") + , dr.GetString("text") + , dr.GetDateTime("createDate") + , dr.GetDateTime("updateDate") + , dr.GetDateTime("versionDate") + , dr.GetString("icon") + , _hc + , dr.GetString("alias") + , dr.GetString("thumbnail") + , dr.GetString("description") + , masterContentType + , dr.GetInt("contentTypeId") + , dr.GetInt("templateId")); if (!dr.IsNull("releaseDate")) _release = dr.GetDateTime("releaseDate"); @@ -1719,7 +1724,7 @@ namespace umbraco.cms.businesslogic.web private void SetupDocumentForTree(Guid uniqueId, int level, int parentId, int creator, int writer, bool publish, string path, string text, DateTime createDate, DateTime updateDate, DateTime versionDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb, - string contentTypeDesc, int? masterContentType, int contentTypeId, int templateId, bool isContainer) + string contentTypeDesc, int? masterContentType, int contentTypeId, int templateId) { SetupNodeForTree(uniqueId, _objectType, level, parentId, creator, path, text, createDate, hasChildren); @@ -1727,7 +1732,7 @@ namespace umbraco.cms.businesslogic.web _published = publish; _updated = updateDate; _template = templateId; - ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, null, isContainer); + ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType); ContentTypeIcon = icon; VersionDate = versionDate; } diff --git a/src/umbraco.cms/businesslogic/web/DocumentType.cs b/src/umbraco.cms/businesslogic/web/DocumentType.cs index 0418824172..f254e1af74 100644 --- a/src/umbraco.cms/businesslogic/web/DocumentType.cs +++ b/src/umbraco.cms/businesslogic/web/DocumentType.cs @@ -34,7 +34,7 @@ namespace umbraco.cms.businesslogic.web new internal const string m_SQLOptimizedGetAll = @" SELECT id, createDate, trashed, parentId, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text, - allowAtRoot, isContainer, Alias,icon,thumbnail,description, + masterContentType,Alias,icon,thumbnail,description, templateNodeId, IsDefault FROM umbracoNode INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId @@ -201,7 +201,7 @@ namespace umbraco.cms.businesslogic.web { if (!_hasChildrenInitialized) { - HasChildren = SqlHelper.ExecuteScalar("select count(childContentTypeId) as tmp from cmsContentType2ContentType where parentContentTypeId = @id", SqlHelper.CreateParameter("@id", Id)) > 0; + HasChildren = SqlHelper.ExecuteScalar("select count(NodeId) as tmp from cmsContentType where masterContentType = " + Id) > 0; } return _hasChildren; } @@ -326,7 +326,7 @@ namespace umbraco.cms.businesslogic.web // check that no document types uses me as a master foreach (DocumentType dt in DocumentType.GetAllAsList()) { - if (dt.MasterContentTypes.Contains(this.Id)) + if (dt.MasterContentType == this.Id) { //this should be InvalidOperationException (or something other than ArgumentException)! throw new ArgumentException("Can't delete a Document Type used as a Master Content Type. Please remove all references first!"); @@ -364,7 +364,6 @@ namespace umbraco.cms.businesslogic.web info.AppendChild(xmlHelper.addTextNode(xd, "Thumbnail", Thumbnail)); info.AppendChild(xmlHelper.addTextNode(xd, "Description", Description)); - //TODO: Add support for mixins! if (this.MasterContentType > 0) { DocumentType dt = new DocumentType(this.MasterContentType); @@ -418,14 +417,14 @@ namespace umbraco.cms.businesslogic.web // tabs XmlElement tabs = xd.CreateElement("Tabs"); - foreach (PropertyTypeGroup t in PropertyTypeGroups) + foreach (TabI t in getVirtualTabs.ToList()) { //only add tabs that aren't from a master doctype - if (t.ContentTypeId == this.Id) + if (t.ContentType == this.Id) { XmlElement tabx = xd.CreateElement("Tab"); tabx.AppendChild(xmlHelper.addTextNode(xd, "Id", t.Id.ToString())); - tabx.AppendChild(xmlHelper.addTextNode(xd, "Caption", t.Name)); + tabx.AppendChild(xmlHelper.addTextNode(xd, "Caption", t.Caption)); tabs.AppendChild(tabx); } } diff --git a/src/umbraco.cms/umbraco.cms.csproj b/src/umbraco.cms/umbraco.cms.csproj index 934e237079..1db1c56de3 100644 --- a/src/umbraco.cms/umbraco.cms.csproj +++ b/src/umbraco.cms/umbraco.cms.csproj @@ -237,7 +237,6 @@ True PackageFiles.resx - diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs index a7078fc0dd..617d1daba3 100644 --- a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs @@ -25,8 +25,7 @@ namespace umbraco.DataLayer.SqlHelpers.MySql /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'cmsContentType2ContentType'", 1, DatabaseVersion.Version4_9), - new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 1, DatabaseVersion.Version4_8), + new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 0, DatabaseVersion.Version4_8), new VersionSpecs("SELECT id FROM umbracoNode WHERE id = -21", 1, DatabaseVersion.Version4_1), new VersionSpecs("SELECT action FROM umbracoAppTree", DatabaseVersion.Version4), new VersionSpecs("SELECT description FROM cmsContentType", DatabaseVersion.Version3), diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Total.sql b/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Total.sql index c6ff50585d..240ad28bf4 100644 --- a/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Total.sql +++ b/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Total.sql @@ -136,23 +136,10 @@ CREATE TABLE cmsContentType pk int NOT NULL PRIMARY KEY AUTO_INCREMENT, nodeId int NOT NULL, alias nvarchar (255) NULL, -icon nvarchar (255) NULL, -isContainer bit NOT NULL DEFAULT 0, -allowAtRoot bit NOT NULL DEFAULT 0 +icon nvarchar (255) NULL ) ; - -CREATE TABLE cmsContentType2ContentType -( -parentContentTypeId int NOT NULL, -childContentTypeId int NOT NULL -) - -; -ALTER TABLE cmsContentType2ContentType ADD CONSTRAINT PK_cmsContentType2ContentType PRIMARY KEY CLUSTERED (parentContentTypeId, childContentTypeId) -; - CREATE TABLE cmsMacroPropertyType ( id smallint NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -178,10 +165,9 @@ stylesheetPropertyValue nvarchar (400) NULL */ -CREATE TABLE cmsPropertyTypeGroup +CREATE TABLE cmsTab ( id int NOT NULL PRIMARY KEY AUTO_INCREMENT, -parentGroupId int NULL DEFAULT NULL, contenttypeNodeId int NOT NULL, text nvarchar (255) NOT NULL, sortorder int NOT NULL @@ -288,7 +274,7 @@ CREATE TABLE cmsPropertyType id int NOT NULL PRIMARY KEY AUTO_INCREMENT, dataTypeId int NOT NULL, contentTypeId int NOT NULL, -propertyTypeGroupId int NULL, +tabId int NULL, Alias nvarchar (255) NOT NULL, Name nvarchar (255) NULL, helpText nvarchar (1000) NULL, @@ -357,8 +343,7 @@ ALTER TABLE umbracoAppTree ADD CONSTRAINT PK_umbracoAppTree PRIMARY KEY CLUSTERE CREATE TABLE cmsContentTypeAllowedContentType ( Id int NOT NULL, -AllowedId int NOT NULL, -SortOrder int NOT NULL DEFAULT 1 +AllowedId int NOT NULL ) ; @@ -534,10 +519,10 @@ INSERT INTO umbracoNode (id, trashed, parentID, nodeUser, level, path, sortOrder (1043, 0, -1, 0, 1, '-1,1042', 2, '1df9f033-e6d4-451f-b8d2-e0cbc50a836f', 'Image Cropper', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '2006/01/03 13:07:55.250') ; -INSERT INTO cmsContentType (pk, nodeId, alias, icon, isContainer, allowAtRoot) VALUES - (532, 1031, 'Folder', 'folder.gif', 1, 1), - (533, 1032, 'Image', 'mediaPhoto.gif', 0, 0), - (534, 1033, 'File', 'mediaFile.gif', 0, 0) +INSERT INTO cmsContentType (pk, nodeId, alias, icon) VALUES + (532, 1031, 'Folder', 'folder.gif'), + (533, 1032, 'Image', 'mediaPhoto.gif'), + (534, 1033, 'File', 'mediaFile.gif') ; INSERT INTO umbracoUserType (id, userTypeAlias, userTypeName, userTypeDefaultPermissions) VALUES (1, 'admin', 'Administrators', 'CADMOSKTPIURZ5:'), @@ -615,12 +600,12 @@ INSERT INTO cmsMacroPropertyType (id, macroPropertyTypeAlias, macroPropertyTypeR (24, 'propertyTypePickerMultiple', 'umbraco.macroRenderings', 'propertyTypePickerMultiple', 'String'), (25, 'textMultiLine', 'umbraco.macroRenderings', 'textMultiple', 'String') ; -INSERT INTO cmsPropertyTypeGroup (id, contenttypeNodeId, text, sortorder) VALUES +INSERT INTO cmsTab (id, contenttypeNodeId, text, sortorder) VALUES (3, 1032, 'Image', 1), (4, 1033, 'File', 1), (5, 1031, 'Contents', 1) ; -INSERT INTO cmsPropertyType (id, dataTypeId, contentTypeId, propertyTypeGroupId, Alias, Name, helpText, sortOrder, mandatory, validationRegExp, Description) VALUES +INSERT INTO cmsPropertyType (id, dataTypeId, contentTypeId, tabId, Alias, Name, helpText, sortOrder, mandatory, validationRegExp, Description) VALUES (6, -90, 1032, 3, 'umbracoFile', 'Upload image', NULL, 0, 0, NULL, NULL), (7, -92, 1032, 3, 'umbracoWidth', 'Width', NULL, 0, 0, NULL, NULL), (8, -92, 1032, 3, 'umbracoHeight', 'Height', NULL, 0, 0, NULL, NULL), @@ -699,7 +684,7 @@ ALTER TABLE cmsContentType ADD FOREIGN KEY (nodeId) REFERENCES umbracoNode (id) ; ALTER TABLE umbracoNode ADD FOREIGN KEY (parentID) REFERENCES umbracoNode (id) ; -ALTER TABLE cmsPropertyType ADD FOREIGN KEY (propertyTypeGroupId) REFERENCES cmsPropertyTypeGroup (id) +ALTER TABLE cmsPropertyType ADD FOREIGN KEY (tabId) REFERENCES cmsTab (id) ; ALTER TABLE cmsContent ADD FOREIGN KEY (nodeId) REFERENCES umbracoNode (id) ; @@ -749,6 +734,8 @@ alter TABLE cmsContentType add thumbnail nvarchar(255) NOT NULL DEFAULT 'folder. ; alter TABLE cmsContentType add description nvarchar(1500) NULL ; +alter TABLE cmsContentType add masterContentType int NULL +; insert into cmsDataTypePreValues (id, dataTypeNodeId, value, sortorder, alias) values (3,-87,',code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|', 0, ''), (4,1041,'default', 0, 'group') @@ -856,8 +843,5 @@ CREATE INDEX IX_Icon ON cmsContentType(nodeId, icon) /* Create Custom Index to speed up tree loading */ CREATE INDEX IX_contentid_versiondate ON cmscontentversion(CONTENTID, VERSIONDATE) ; -ALTER TABLE cmsPropertyTypeGroup ADD FOREIGN KEY (parentGroupId) REFERENCES cmsPropertyTypeGroup (id) -; - /* CHANGE:End */ diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Version4_8_Upgrade.sql b/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Version4_8_Upgrade.sql deleted file mode 100644 index d84b16b507..0000000000 --- a/src/umbraco.datalayer/SqlHelpers/MySql/Sql/Version4_8_Upgrade.sql +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************************* - - Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) - - IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - - Database version: 4.10.0.0 - - Please increment this version number if ANY change is made to this script, - so compatibility with scripts for other database systems can be verified easily. - The first 3 digits depict the Umbraco version, the last digit is the database version. - (e.g. version 4.0.0.3 means "Umbraco version 4.0.0, database version 3") - - Check-in policy: only commit this script if - * you ran the Umbraco installer completely; - * you ran it on the targetted database system; - * you ran the Runway and Module installations; - * you were able to browse the Boost site; - * you were able to open the Umbraco administration panel; - * you have documented the code change in this script; - * you have incremented the version number in this script. - - IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - -********************************************************************************************/ --- rename cmsTab -RENAME TABLE cmsTab TO cmsPropertyTypeGroup; -; --- add parent Group to new cmsPropertyTypeGroup -ALTER TABLE cmsPropertyTypeGroup -ADD parentGroupId int NULL DEFAULT NULL -; -ALTER TABLE cmsPropertyType -ADD FOREIGN KEY (propertyTypeGroupId) -REFERENCES cmsPropertyTypeGroup (id) -; --- add sortOrder to cmsContentTypeAllowedContentType -ALTER TABLE cmsContentTypeAllowedContentType -ADD sortOrder int NOT NULL DEFAULT 1 -; --- add container and allowAtRoot to cmsContentType -ALTER TABLE cmsContentType -ADD isContainer int NOT NULL DEFAULT 0 -; -ALTER TABLE cmsContentType -ADD allowAtRoot int NOT NULL DEFAULT 0 -; -CREATE TABLE cmsContentType2ContentType -(parentContentTypeId int NOT NULL, childContentTypeId int NOT NULL) -; -ALTER TABLE cmsContentType2ContentType ADD CONSTRAINT PK_cmsContentType2ContentType PRIMARY KEY CLUSTERED (parentContentTypeId, childContentTypeId) -; --- move all masterContentType information to new cmsContentType2ContentType table -INSERT INTO cmsContentType2ContentType (parentContentTypeId, childContentTypeId) -select masterContentType, nodeId from cmsContentType WHERE not masterContentType is null and masterContentType != 0 -; --- remove masterContentType column from cmsContentType now that it's replaced by a separate table -ALTER TABLE cmsContentType DROP COLUMN masterContentType -; --- rename tab to propertyGroup on propertyType -ALTER TABLE cmsPropertyType ADD propertyTypeGroupId int -; -UPDATE cmsPropertyType SET propertyTypeGroupId = tabId -; -ALTER TABLE cmsPropertyType DROP FOREIGN KEY FK_cmsPropertyType_cmsTab -; -ALTER TABLE cmsPropertyType DROP COLUMN tabId -; diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Total.sql b/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Total.sql index af94a7d9f2..3153fe3a46 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Total.sql +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Total.sql @@ -10,7 +10,7 @@ IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - Database version: 4.10.0.0 + Database version: 4.8.0.3 Please increment this version number if ANY change is made to this script, so compatibility with scripts for other database systems can be verified easily. @@ -152,23 +152,12 @@ CREATE TABLE [cmsContentType] [pk] [int] NOT NULL IDENTITY(1, 1), [nodeId] [int] NOT NULL, [alias] [nvarchar] (255) NULL, -[icon] [nvarchar] (255) NULL, -[isContainer] [bit] NOT NULL CONSTRAINT [df_cmsContentType_isContainer] DEFAULT 0, -[allowAtRoot] [bit] NOT NULL CONSTRAINT [df_cmsContentType_allowAtRoot] DEFAULT 0 +[icon] [nvarchar] (255) NULL ) ; ALTER TABLE [cmsContentType] ADD CONSTRAINT [PK_cmsContentType] PRIMARY KEY CLUSTERED ([pk]) ; -CREATE TABLE [cmsContentType2ContentType]( - [parentContentTypeId] [int] NOT NULL, - [childContentTypeId] [int] NOT NULL, - CONSTRAINT [PK_cmsContentType2ContentType] PRIMARY KEY CLUSTERED -( - [parentContentTypeId] ASC, - [childContentTypeId] ASC -)) -; CREATE TABLE [cmsMacroPropertyType] ( [id] [smallint] NOT NULL IDENTITY(1, 1), @@ -200,17 +189,16 @@ ALTER TABLE [umbracoStylesheetProperty] ADD CONSTRAINT [PK_stylesheetProperty] P */ -CREATE TABLE [cmsPropertyTypeGroup] +CREATE TABLE [cmsTab] ( [id] [int] NOT NULL IDENTITY(1, 1), -[parentGroupId] [int] NULL CONSTRAINT [df_cmsPropertyTypeGroup_parentGroupId] DEFAULT NULL, [contenttypeNodeId] [int] NOT NULL, [text] [nvarchar] (255) NOT NULL, [sortorder] [int] NOT NULL ) ; -ALTER TABLE [cmsPropertyTypeGroup] ADD CONSTRAINT [PK_cmsPropertyTypeGroup] PRIMARY KEY CLUSTERED ([id]) +ALTER TABLE [cmsTab] ADD CONSTRAINT [PK_cmsTab] PRIMARY KEY CLUSTERED ([id]) ; CREATE TABLE [cmsTemplate] ( @@ -321,7 +309,7 @@ CREATE TABLE [cmsPropertyType] [id] [int] NOT NULL IDENTITY(1, 1), [dataTypeId] [int] NOT NULL, [contentTypeId] [int] NOT NULL, -[propertyTypeGroupId] [int] NULL, +[tabId] [int] NULL, [Alias] [nvarchar] (255) NOT NULL, [Name] [nvarchar] (255) NULL, [helpText] [nvarchar] (1000) NULL, @@ -398,8 +386,7 @@ ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [PK_umbracoAppTree] PRIMARY KEY CLUS CREATE TABLE [cmsContentTypeAllowedContentType] ( [Id] [int] NOT NULL, -[AllowedId] [int] NOT NULL, -[SortOrder] [int] NOT NULL CONSTRAINT [df_cmsContentTypeAllowedContentType_sortOrder] DEFAULT 1 +[AllowedId] [int] NOT NULL ) ; @@ -596,7 +583,7 @@ ALTER TABLE [cmsContentType] ADD CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) ; ALTER TABLE [cmsPropertyType] ADD -CONSTRAINT [FK_cmsPropertyType_cmsPropertyTypeGroup] FOREIGN KEY ([propertyTypeGroupId]) REFERENCES [cmsPropertyTypeGroup] ([id]) +CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) ; ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) @@ -607,7 +594,7 @@ CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umb ALTER TABLE [cmsTemplate] DROP CONSTRAINT [FK_cmsTemplate_umbracoNode] ; -ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsPropertyTypeGroup] +ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab] ; ALTER TABLE [cmsContent] DROP CONSTRAINT [FK_cmsContent_umbracoNode] ; @@ -668,7 +655,7 @@ INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [pa SET IDENTITY_INSERT [umbracoNode] OFF ; SET IDENTITY_INSERT [cmsContentType] ON -INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon], [isContainer], [allowAtRoot]) VALUES (532, 1031, N'Folder', N'folder.gif', 1, 1) +INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (532, 1031, N'Folder', N'folder.gif') INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (533, 1032, N'Image', N'mediaPhoto.gif') INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (534, 1033, N'File', N'mediaFile.gif') SET IDENTITY_INSERT [cmsContentType] OFF @@ -709,22 +696,22 @@ INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroProper INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (25, N'textMultiLine', N'umbraco.macroRenderings', N'textMultiple', N'String') SET IDENTITY_INSERT [cmsMacroPropertyType] OFF ; -SET IDENTITY_INSERT [cmsPropertyTypeGroup] ON -INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1) -INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1) -INSERT INTO [cmsPropertyTypeGroup] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1) -SET IDENTITY_INSERT [cmsPropertyTypeGroup] OFF +SET IDENTITY_INSERT [cmsTab] ON +INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1) +INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1) +INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1) +SET IDENTITY_INSERT [cmsTab] OFF ; SET IDENTITY_INSERT [cmsPropertyType] ON -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [propertyTypeGroupId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) +INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL) SET IDENTITY_INSERT [cmsPropertyType] OFF ; SET IDENTITY_INSERT [umbracoLanguage] ON @@ -773,7 +760,7 @@ INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (40, 10 SET IDENTITY_INSERT [cmsDataType] OFF ; ALTER TABLE [cmsTemplate] ADD CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsPropertyTypeGroup] FOREIGN KEY ([propertyTypeGroupId]) REFERENCES [cmsPropertyTypeGroup] ([id]) +ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id]) ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]) @@ -870,6 +857,11 @@ SELECT DISTINCT userID, nodeId, 'H' FROM umbracoUser2NodePermission WHERE userId (SELECT umbracoUser.id FROM umbracoUserType INNER JOIN umbracoUser ON umbracoUserType.id = umbracoUser.userType WHERE (umbracoUserType.userTypeAlias = 'writer')) ; +alter TABLE [cmsContentType] +add [masterContentType] int NULL CONSTRAINT +[DF_cmsContentType_masterContentType] DEFAULT (0) +; + CREATE TABLE [cmsTagRelationship]( [nodeId] [int] NOT NULL, [tagId] [int] NOT NULL, @@ -1312,8 +1304,8 @@ ALTER TABLE cmsPropertyType ADD CONSTRAINT ON DELETE NO ACTION ; -ALTER TABLE cmsPropertyTypeGroup ADD CONSTRAINT - FK_cmsPropertyTypeGroup_cmsContentType FOREIGN KEY +ALTER TABLE cmsTab ADD CONSTRAINT + FK_cmsTab_cmsContentType FOREIGN KEY ( contenttypeNodeId ) REFERENCES cmsContentType @@ -1596,10 +1588,7 @@ ALTER TABLE cmsMember2MemberGroup ADD CONSTRAINT ) ON UPDATE NO ACTION ON DELETE NO ACTION ; -ALTER TABLE [cmsPropertyTypeGroup] -WITH CHECK ADD CONSTRAINT [FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup] FOREIGN KEY([parentGroupId]) -REFERENCES [cmsPropertyTypeGroup] ([id]) -; + /*********************************************************************************************************************** diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Version4_8_Upgrade.sql b/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Version4_8_Upgrade.sql deleted file mode 100644 index dd9a7e5977..0000000000 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/Sql/Version4_8_Upgrade.sql +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************************* - - Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) - - IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - - Database version: 4.10.0.0 - - Please increment this version number if ANY change is made to this script, - so compatibility with scripts for other database systems can be verified easily. - The first 3 digits depict the Umbraco version, the last digit is the database version. - (e.g. version 4.0.0.3 means "Umbraco version 4.0.0, database version 3") - - Check-in policy: only commit this script if - * you ran the Umbraco installer completely; - * you ran it on the targetted database system; - * you ran the Runway and Module installations; - * you were able to browse the Boost site; - * you were able to open the Umbraco administration panel; - * you have documented the code change in this script; - * you have incremented the version number in this script. - - IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - -********************************************************************************************/ --- rename cmsTab -SP_RENAME 'cmsTab', 'cmsPropertyTypeGroup' -; --- add parent Group to new cmsPropertyTypeGroup -ALTER TABLE [cmsPropertyTypeGroup] -ADD [parentGroupId] int NULL -CONSTRAINT [df_cmsPropertyTypeGroup_parentGroupId] DEFAULT NULL -; -ALTER TABLE [cmsPropertyTypeGroup] -ADD CONSTRAINT [FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup] FOREIGN KEY([parentGroupId]) -REFERENCES [cmsPropertyTypeGroup] ([id]) -; --- add sortOrder to cmsContentTypeAllowedContentType -ALTER TABLE [cmsContentTypeAllowedContentType] -ADD [sortOrder] int NOT NULL -CONSTRAINT [df_cmsContentTypeAllowedContentType_sortOrder] DEFAULT 1 -; --- add container and allowAtRoot to cmsContentType -ALTER TABLE [cmsContentType] -ADD [isContainer] bit NOT NULL -CONSTRAINT [df_cmsContentType_isContainer] DEFAULT 0 -; -ALTER TABLE [cmsContentType] -ADD [allowAtRoot] bit NOT NULL -CONSTRAINT [df_cmsContentType_allowAtRoot] DEFAULT 0 -; --- Create a new cmsContentType2ContentType table -CREATE TABLE [cmsContentType2ContentType] ([parentContentTypeId] int NOT NULL,[childContentTypeId] int NOT NULL) -; -ALTER TABLE [cmsContentType2ContentType] ADD CONSTRAINT [cmsContentType2ContentType_PK] PRIMARY KEY ([parentContentTypeId],[childContentTypeId]) -; --- move all masterContentType information to new cmsContentType2ContentType table -INSERT INTO [cmsContentType2ContentType] (parentContentTypeId, childContentTypeId) -select masterContentType, nodeId from [cmsContentType] WHERE not [masterContentType] is null and [masterContentType] != 0 -; --- remove masterContentType column from cmsContentType now that it's replaced by a separate table -ALTER TABLE [cmsContentType] DROP CONSTRAINT [DF_cmsContentType_masterContentType] -; -ALTER TABLE [cmsContentType] DROP COLUMN [masterContentType] -; --- rename tab to propertyGroup on propertyType -ALTER TABLE [cmsPropertyType] ADD [propertyTypeGroupId] int -; -UPDATE [cmsPropertyType] SET [propertyTypeGroupId] = [tabId] -; -ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab] -; -ALTER TABLE [cmsPropertyType] DROP COLUMN [tabId] -; diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.Designer.cs b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.Designer.cs index 4fd699fe96..680984863d 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.Designer.cs +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.Designer.cs @@ -129,25 +129,6 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer { } } - /// - /// Looks up a localized string similar to /******************************************************************************************* - /// - /// Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) - /// - /// IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - /// - /// Database version: 4.8.0.0 - /// - /// Please increment this version number if ANY change is made to this script, - /// so compatibility with scripts for other database systems can be verified easily. - /// The first 3 digits depict [rest of string was truncated]";. - /// - internal static string Version4_8_Upgrade { - get { - return ResourceManager.GetString("Version4_8_Upgrade", resourceCulture); - } - } - /// /// Looks up a localized string similar to /******************************************************************************************* /// diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.resx b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.resx index 90dd03d575..7e998a0485 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.resx +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlResources.resx @@ -127,9 +127,6 @@ sql\version4_1_upgrade.sql;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - - sql\version4_8_upgrade.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - sql\version4_upgrade.sql;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs index 3f9dda0236..74918e459b 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs @@ -20,14 +20,11 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer #region Private Constants /// The latest database version this installer supports. - private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_9; + private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8; /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'cmsContentType2ContentType'", 1, DatabaseVersion.Version4_9), - //This will throw an exception and will only ever have one row if it is installed, on exception the database version returned is unkown so will still work. - //NOTE: before this was set to zero and only worked by fluke! - new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 1, DatabaseVersion.Version4_8), + new VersionSpecs("SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS LEFT OUTER JOIN umbracoApp ON appAlias = appAlias WHERE CONSTRAINT_NAME = 'FK_umbracoUser2app_umbracoApp'", 0, DatabaseVersion.Version4_8), new VersionSpecs("SELECT id FROM umbracoNode WHERE id = -21", 1, DatabaseVersion.Version4_1), new VersionSpecs("SELECT action FROM umbracoAppTree", DatabaseVersion.Version4), new VersionSpecs("SELECT description FROM cmsContentType", DatabaseVersion.Version3), diff --git a/src/umbraco.datalayer/Utility/Installer/DatabaseVersion.cs b/src/umbraco.datalayer/Utility/Installer/DatabaseVersion.cs index 1ffcce7227..fc9841cc7a 100644 --- a/src/umbraco.datalayer/Utility/Installer/DatabaseVersion.cs +++ b/src/umbraco.datalayer/Utility/Installer/DatabaseVersion.cs @@ -24,8 +24,6 @@ namespace umbraco.DataLayer.Utility.Installer /// Umbraco version 4.1. Version4_1, /// Umbraco version 4.8. - Version4_8, - /// Umbraco version 4.9. - Version4_9 + Version4_8 } } diff --git a/src/umbraco.datalayer/umbraco.datalayer.csproj b/src/umbraco.datalayer/umbraco.datalayer.csproj index 5def3d5cb7..73d169333e 100644 --- a/src/umbraco.datalayer/umbraco.datalayer.csproj +++ b/src/umbraco.datalayer/umbraco.datalayer.csproj @@ -189,12 +189,8 @@ - - - - {31785bc3-256c-4613-b2f5-a1b0bdded8c1} diff --git a/src/umbraco.editorControls/ultimatepicker/ultimatePickerDataEditor.cs b/src/umbraco.editorControls/ultimatepicker/ultimatePickerDataEditor.cs index 5922cfa550..865c7c3364 100644 --- a/src/umbraco.editorControls/ultimatepicker/ultimatePickerDataEditor.cs +++ b/src/umbraco.editorControls/ultimatepicker/ultimatePickerDataEditor.cs @@ -113,22 +113,22 @@ namespace umbraco.editorControls.ultimatepicker case "AutoComplete": if (childtxt.Text.Contains("[") && childtxt.Text.Contains("]")) { - dataToSave = childtxt.Text.Replace("]", "").Split("[".ToCharArray())[1]; + dataToSave = childtxt.Text.Replace("]","").Split("[".ToCharArray())[1]; } - + break; case "auto-suggest": goto case "AutoComplete"; case "CheckBoxList": - if (checkboxlistNodes != null) - foreach (ListItem item in checkboxlistNodes.Items) + + foreach (ListItem item in checkboxlistNodes.Items) + { + if (item.Selected) { - if (item.Selected) - { - dataToSave += item.Value + ","; - } + dataToSave += item.Value + ","; } + } if (dataToSave.Length > 0) { @@ -204,8 +204,7 @@ namespace umbraco.editorControls.ultimatepicker if (dataToSave.Length > 0) { this._data.Value = dataToSave; - } - else + }else { if (childtxt.Text.Trim().Length == 0) { @@ -304,7 +303,7 @@ namespace umbraco.editorControls.ultimatepicker void clearRadiobuttonlist_Click(object sender, EventArgs e) { - + foreach (ListItem radiobutton in radiobuttonlistNodes.Items) { @@ -314,7 +313,7 @@ namespace umbraco.editorControls.ultimatepicker clearRadiobuttons.Checked = true; } - + /// /// Adds sub nodes to the ListControl object passed into the method, based on the Content node passed in @@ -385,7 +384,7 @@ namespace umbraco.editorControls.ultimatepicker ClientDependencyLoader.Instance.RegisterDependency("Application/JQuery/jquery.autocomplete.js", "UmbracoClient", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency("css/umbracoGui.css", "UmbracoRoot", ClientDependencyType.Css); - + childtxt = new TextBox(); childtxt.ID = "ultimatePickerBox" + base.ID; childtxt.AutoCompleteType = AutoCompleteType.Disabled;