From 5f95575141e37ef772639eab1e88539281da8c50 Mon Sep 17 00:00:00 2001 From: agrath Date: Thu, 26 Jul 2012 15:36:34 -1200 Subject: [PATCH 01/24] Fixed a NRE in FileHandlerData when user has not updated umbracoSettings.config to add the new /settings/content/imaging/autoFillImageProperties node --- .../businesslogic/datatype/FileHandlerData.cs | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs index 5f2262cb6e..0b856bf733 100644 --- a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs +++ b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs @@ -83,28 +83,31 @@ namespace umbraco.cms.businesslogic.datatype // check for auto fill of other properties (width, height, extension and filesize) string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias; - XmlNode uploadFieldConfigNode = - UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( - string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); - if (uploadFieldConfigNode != null) + if (UmbracoSettings.ImageAutoFillImageProperties != null) { - // get the current document - Content content = Content.GetContentFromVersion(Version); - // only add dimensions to web images - if (um.SupportsResizing) + XmlNode uploadFieldConfigNode = + UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( + string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); + if (uploadFieldConfigNode != null) { - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", - um.GetDimensions().Item1); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", - um.GetDimensions().Item2); + // get the current document + Content content = Content.GetContentFromVersion(Version); + // only add dimensions to web images + if (um.SupportsResizing) + { + updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", + um.GetDimensions().Item1); + updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", + um.GetDimensions().Item2); + } + else + { + updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); + } + updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", um.Length); + updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", um.Extension); } - else - { - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); - } - updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", um.Length); - updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", um.Extension); } base.Value = um.LocalName; From fffbd960c1dee6beed9ed2c81b2220650089219f Mon Sep 17 00:00:00 2001 From: agrath Date: Thu, 26 Jul 2012 16:05:44 -1200 Subject: [PATCH 02/24] Another NRE that I missed --- .../businesslogic/datatype/FileHandlerData.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs index 0b856bf733..f34677c4dc 100644 --- a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs +++ b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs @@ -132,18 +132,21 @@ namespace umbraco.cms.businesslogic.datatype private void clearRelatedValues() { string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias; - XmlNode uploadFieldConfigNode = - UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( - string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); - if (uploadFieldConfigNode != null) + if (UmbracoSettings.ImageAutoFillImageProperties != null) { - // get the current document - Content content = Content.GetContentFromVersion(Version); - // only add dimensions to web images - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", String.Empty); + XmlNode uploadFieldConfigNode = + UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( + string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); + if (uploadFieldConfigNode != null) + { + // get the current document + Content content = Content.GetContentFromVersion(Version); + // only add dimensions to web images + updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", String.Empty); + } } } From e43d4e4081c0bd4409f6ff56b59f68e8099ebda7 Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Thu, 2 Aug 2012 13:51:47 -0100 Subject: [PATCH 03/24] Opened up a new 4.8.1 branch as the first one was from the wrong point (I didn't realize a bunch of pull requests had been pulled in) --- src/umbraco.presentation/web.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.presentation/web.config b/src/umbraco.presentation/web.config index 2ff11fd5c5..03adb3e518 100644 --- a/src/umbraco.presentation/web.config +++ b/src/umbraco.presentation/web.config @@ -3,7 +3,7 @@
- +
From 3fe9a63957937d62974561446ce7df01925413da Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Thu, 2 Aug 2012 09:51:06 -0100 Subject: [PATCH 04/24] Added fix to database installers to make sure they run the upgrade scripts. --- src/SQLCE4Umbraco/SqlCEInstaller.cs | 5 ++-- .../SqlHelpers/MySql/MySqlInstaller.cs | 5 ++-- .../SqlServer/SqlServerInstaller.cs | 5 ++-- .../Installer/DefaultInstallerUtility.cs | 24 +++++++++++++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/SQLCE4Umbraco/SqlCEInstaller.cs b/src/SQLCE4Umbraco/SqlCEInstaller.cs index 8496eebc87..d5558544d8 100644 --- a/src/SQLCE4Umbraco/SqlCEInstaller.cs +++ b/src/SQLCE4Umbraco/SqlCEInstaller.cs @@ -22,10 +22,11 @@ namespace SqlCE4Umbraco #region Private Constants /// The latest database version this installer supports. - private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_1; + private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8; /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoAppTree_umbracoApp", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), @@ -58,7 +59,7 @@ namespace SqlCE4Umbraco { get { - return false; + return CurrentVersion == DatabaseVersion.Version4_1; } } diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs index 719bbff3dd..c11137dfe4 100644 --- a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs @@ -21,10 +21,11 @@ namespace umbraco.DataLayer.SqlHelpers.MySql #region Private Constants /// The latest database version this installer supports. - private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_1; + private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8; /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoAppTree_umbracoApp", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), @@ -45,7 +46,7 @@ namespace umbraco.DataLayer.SqlHelpers.MySql { get { - return CurrentVersion == DatabaseVersion.Version4; + return CurrentVersion == DatabaseVersion.Version4_1; } } diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs index 32603b85ed..2c9e11e35f 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs @@ -20,10 +20,11 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer #region Private Constants /// The latest database version this installer supports. - private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_1; + private const DatabaseVersion LatestVersionSupported = DatabaseVersion.Version4_8; /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoAppTree_umbracoApp", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), @@ -44,7 +45,7 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer { get { - return CurrentVersion == DatabaseVersion.Version4; + return CurrentVersion == DatabaseVersion.Version4_1; } } diff --git a/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs b/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs index 05c71d202c..5958150166 100644 --- a/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs +++ b/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs @@ -198,7 +198,8 @@ namespace umbraco.DataLayer.Utility.Installer if (!String.IsNullOrEmpty(v.Table) && !String.IsNullOrEmpty(v.Field) && !String.IsNullOrEmpty(v.Value)) { IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT {0} FROM {1} WHERE {0}={2}", v.Field, v.Table, v.Value)); - if (!reader.Read()) + var canRead = reader.Read(); + if ((v.ShouldExist && !canRead) || (!v.ShouldExist && canRead)) continue; } else if (String.IsNullOrEmpty(v.Table)) @@ -257,6 +258,8 @@ namespace umbraco.DataLayer.Utility.Installer /// The value to look for in the field, if this is left empty it will not be queried. /// public readonly string Value; + /// Boolean flag indicating whether the value should or shouldn't exist. + public readonly bool ShouldExist; /// The minimum version number of a database that contains the specified field. public readonly DatabaseVersion Version; @@ -273,6 +276,7 @@ namespace umbraco.DataLayer.Utility.Installer Table = table; Version = version; Value = ""; + ShouldExist = true; } /// @@ -286,7 +290,23 @@ namespace umbraco.DataLayer.Utility.Installer Field = field; Table = table; Value = value; - Version = version; + Version = version; + ShouldExist = true; } + + /// + /// Initializes a new instance of the struct. + /// + /// The field. + /// The table. + /// The version. + public VersionSpecs(string field, string table, string value, bool shouldExist, DatabaseVersion version) + { + Field = field; + Table = table; + Value = value; + Version = version; + ShouldExist = shouldExist; + } } } From f6beeab813d8483d8653e5df51d3f191d7721a29 Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Thu, 2 Aug 2012 13:55:45 -0100 Subject: [PATCH 05/24] Added fixed SQL CE Upgrade script --- src/SQLCE4Umbraco/Sql/Version4_1_Upgrade.sql | 135 +----------------- src/SQLCE4Umbraco/SqlCEResources1.Designer.cs | 6 +- 2 files changed, 8 insertions(+), 133 deletions(-) diff --git a/src/SQLCE4Umbraco/Sql/Version4_1_Upgrade.sql b/src/SQLCE4Umbraco/Sql/Version4_1_Upgrade.sql index 926d486946..d58ebc28a2 100644 --- a/src/SQLCE4Umbraco/Sql/Version4_1_Upgrade.sql +++ b/src/SQLCE4Umbraco/Sql/Version4_1_Upgrade.sql @@ -1,6 +1,6 @@ /******************************************************************************************* - Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) + Umbraco database installation script for SQL CE (upgrade from Umbraco 4.0.x) IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT @@ -24,133 +24,8 @@ ********************************************************************************************/ -/* INSERT NEW MEDIA RECYCLE BIN NODE */ -SET IDENTITY_INSERT [umbracoNode] ON -INSERT INTO umbracoNode (id, trashed, parentID, nodeUser, level, path, sortOrder, uniqueID, text, nodeObjectType) -VALUES (-21, 0, -1, 0, 0, '-1,-21', 0, 'BF7C7CBC-952F-4518-97A2-69E9C7B33842', 'Recycle Bin', 'CF3D8E34-1C1C-41e9-AE56-878B57B32113') -SET IDENTITY_INSERT [umbracoNode] OFF +/* REMOVE CONSTRAINTS */ +ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoApp] ; -/* Add the mediaRecycleBin tree type */ -IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='mediaRecycleBin') -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 0, 0, 'media', 'mediaRecycleBin', 'RecycleBin', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.MediaRecycleBin') -; - - -CREATE TABLE [cmsPreviewXml]( - [nodeId] [int] NOT NULL, - [versionId] [uniqueidentifier] NOT NULL, - [timestamp] [datetime] NOT NULL, - [xml] [ntext] NOT NULL, - CONSTRAINT [PK_cmsContentPreviewXml] PRIMARY KEY CLUSTERED -( - [nodeId] ASC, - [versionId] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -) - - -/************************** CLEANUP ***********************************************/ - -/* DELETE NON-EXISTING DOCUMENTS */ -delete from cmsDocument where nodeId not in (select id from umbracoNode) -; - -/* CLEAN UNUSED CONTENT ROWS */ -delete from cmsContent where nodeId not in (select id from umbracoNode) -; - -/* CLEAN UNUSED VERSIONS */ -delete from cmsContentVersion where contentid not in (select nodeId from cmsContent) -; - -/* CLEAN UNUSED XML */ -delete from cmsContentXml where nodeid not in (select nodeId from cmsContent) -; - -/* CLEAN UNUSED DOCUMENT TYPES */ -delete from cmsDocumentType where contentTypeNodeId not in (select nodeId from cmsContentType) -; -delete from cmsDocumentType where templateNodeId not in (select nodeid from cmsTemplate) -; - -/* UPDATE EMPTY TEMPLATE REFERENCES IN DOCUMENTS */ -update cmsDocument set templateId = NULL where templateId not in (select nodeId from cmsTemplate) -; - -/* DELETE ALL NOTIFICATIONS THAT NO LONGER HAVE NODES */ -delete from umbracoUser2NodeNotify where nodeId not in (select id from umbracoNode) -; - -/* DELETE ALL NOTIFICATIONS THAT NO LONGER HAVE USERS */ -delete from umbracoUser2NodeNotify where userId not in (select id from umbracoUser) -; - -/* DELETE UMBRACO NODE DATA THAT IS FLAGGED AS A DOCUMENT OBJECT TYPE THAT DOESN'T EXIST IN THE CONTENT TABLE ANY LONGER */ -delete from umbracoNode where id not in -(select nodeId from cmsContent) and nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972' -; - -/* DELETE PERMISSIONS THAT RELATED TO NON-EXISTING USERS */ -delete from umbracoUser2NodePermission where userId not in (select id from umbracoUser) -; - -/* DELETE PERMISSIONS THAT RELATED TO NON-EXISTING NODES */ -delete from umbracoUser2NodePermission where nodeId not in (select id from umbracoNode) -; - -/* SET MASTER TEMPLATE TO NULL WHEN THERE ISN'T ONE SPECIFIED */ -update cmsTemplate set [master] = NULL where [master] = 0 - -/* -We need to remove any data type that doesn't exist in umbracoNode as these shouldn't actually exist -I think they must be left over from how Umbraco used to show the types of data types registered instead -of using reflection. Here are the data types in the cmsDataType table that are not in umbracoNode: - -12 -91 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -22 -44 A3776494-0574-4D93-B7DE-EFDFDEC6F2D1 Ntext -23 -128 A52C7C1C-C330-476E-8605-D63D3B84B6A6 Nvarchar -24 -129 928639ED-9C73-4028-920C-1E55DBB68783 Nvarchar -25 -130 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -26 -131 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -27 -132 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -28 -133 6C738306-4C17-4D88-B9BD-6546F3771597 Ntext -29 -134 928639ED-9C73-4028-920C-1E55DBB68783 Nvarchar -30 -50 AAF99BB2-DBBE-444D-A296-185076BF0484 Date -39 1042 5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83 Ntext -40 1043 5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83 Ntext -41 1044 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Ntext -42 1045 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Ntext -47 1194 D15E1281-E456-4B24-AA86-1DDA3E4299D5 Ntext - -*/ -DELETE FROM cmsDataType WHERE nodeId NOT IN (SELECT id FROM umbracoNode) -; - -/* Need to remove any data type prevalues that aren't related to a data type */ -DELETE FROM cmsDataTypePreValues WHERE dataTypeNodeID NOT IN (SELECT nodeId FROM cmsDataType) -; - -/* Remove any domains that should not exist as they weren't deleted before when documents were deleted */ -DELETE FROM umbracoDomains WHERE domainRootStructureId NOT IN (SELECT id FROM umbracoNode) -; - --- It would be good to add constraints from cmsLanguageText to umbracoLanguage but unfortunately, a 'zero' id --- is entered into cmsLanguageText when a new entry is made, since there's not language with id of zero this won't work. --- However, we need to remove translations that aren't related to a language (these would be left over from deleting a language) -DELETE FROM cmsLanguageText -WHERE languageId <> 0 AND languageId NOT IN (SELECT id FROM umbracoLanguage) -; - -/* need to remove any content restrictions that don't exist in cmsContent */ - -DELETE FROM cmsContentTypeAllowedContentType WHERE id NOT IN (SELECT nodeId FROM cmsContentType) -; -DELETE FROM cmsContentTypeAllowedContentType WHERE Allowedid NOT IN (SELECT nodeId FROM cmsContentType) -; - -/* Though this should not have to be run because it's a new install, you need to clean the previews if you've been testing before the RC */ -DELETE FROM cmsPreviewXml WHERE VersionID NOT IN (SELECT VersionId FROM cmsContentVersion) -; - -/************************** CLEANUP END ********************************************/ +ALTER TABLE [umbracoAppTree] DROP CONSTRAINT [FK_umbracoAppTree_umbracoApp] +; \ No newline at end of file diff --git a/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs b/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs index 9fc552f5c8..ebc7ed1154 100644 --- a/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs +++ b/src/SQLCE4Umbraco/SqlCEResources1.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.269 +// Runtime Version:4.0.30319.17626 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -88,7 +88,7 @@ namespace SQLCE4Umbraco { /// /// Looks up a localized string similar to /******************************************************************************************* /// - /// Umbraco database installation script for SQL Server (upgrade from Umbraco 4.0.x) + /// Umbraco database installation script for SQL CE (upgrade from Umbraco 4.0.x) /// /// IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT /// @@ -96,7 +96,7 @@ namespace SQLCE4Umbraco { /// /// 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]";. + /// The first 3 digits depict the [rest of string was truncated]";. /// internal static string Version4_1_Upgrade { get { From 90fffd32167977156ed263b13bf081618b6c3fc6 Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Thu, 2 Aug 2012 14:09:41 -0100 Subject: [PATCH 06/24] Updated version number in global settings --- src/umbraco.businesslogic/GlobalSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.businesslogic/GlobalSettings.cs b/src/umbraco.businesslogic/GlobalSettings.cs index bd0d5df807..218bdd81ce 100644 --- a/src/umbraco.businesslogic/GlobalSettings.cs +++ b/src/umbraco.businesslogic/GlobalSettings.cs @@ -18,7 +18,7 @@ namespace umbraco { #region Private static fields // CURRENT UMBRACO VERSION ID - private static string _currentVersion = "4.8.0"; + private static string _currentVersion = "4.8.1"; private static string _reservedUrlsCache; private static string _reservedPathsCache; From 2a55868846638eaf22743ed667081ee3bcad10c1 Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Thu, 2 Aug 2012 14:38:48 -0100 Subject: [PATCH 07/24] Changed the DB Installer scripts to check a different constraint (the one that causes the main problems) --- src/SQLCE4Umbraco/SqlCEInstaller.cs | 2 +- src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs | 2 +- .../SqlHelpers/SqlServer/SqlServerInstaller.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SQLCE4Umbraco/SqlCEInstaller.cs b/src/SQLCE4Umbraco/SqlCEInstaller.cs index d5558544d8..9e71a39e51 100644 --- a/src/SQLCE4Umbraco/SqlCEInstaller.cs +++ b/src/SQLCE4Umbraco/SqlCEInstaller.cs @@ -26,7 +26,7 @@ namespace SqlCE4Umbraco /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoAppTree_umbracoApp", false, DatabaseVersion.Version4_8), + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoUser2app_umbracoApp", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs index c11137dfe4..124ea44d59 100644 --- a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs @@ -25,7 +25,7 @@ namespace umbraco.DataLayer.SqlHelpers.MySql /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoAppTree_umbracoApp", false, DatabaseVersion.Version4_8), + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoUser2app_umbracoApp", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs index 2c9e11e35f..377bcfda48 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs @@ -24,7 +24,7 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoAppTree_umbracoApp", false, DatabaseVersion.Version4_8), + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoUser2app_umbracoApp", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), From c5adb6a2e1adb2c71c93a8cb80ecd47cac7e89cc Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Thu, 2 Aug 2012 14:58:39 -0100 Subject: [PATCH 08/24] Updated field value check to surround value with quotes --- src/SQLCE4Umbraco/SqlCEInstaller.cs | 2 +- src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs | 2 +- .../SqlHelpers/SqlServer/SqlServerInstaller.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SQLCE4Umbraco/SqlCEInstaller.cs b/src/SQLCE4Umbraco/SqlCEInstaller.cs index 9e71a39e51..4f85b13a2d 100644 --- a/src/SQLCE4Umbraco/SqlCEInstaller.cs +++ b/src/SQLCE4Umbraco/SqlCEInstaller.cs @@ -26,7 +26,7 @@ namespace SqlCE4Umbraco /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoUser2app_umbracoApp", false, DatabaseVersion.Version4_8), + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "'FK_umbracoUser2app_umbracoApp'", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs index 124ea44d59..ad9892a2a5 100644 --- a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs @@ -25,7 +25,7 @@ namespace umbraco.DataLayer.SqlHelpers.MySql /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoUser2app_umbracoApp", false, DatabaseVersion.Version4_8), + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "'FK_umbracoUser2app_umbracoApp'", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs index 377bcfda48..4b735e0504 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs @@ -24,7 +24,7 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "FK_umbracoUser2app_umbracoApp", false, DatabaseVersion.Version4_8), + new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "'FK_umbracoUser2app_umbracoApp'", false, DatabaseVersion.Version4_8), new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), From 29ec45d9e27fd568904add45864fe817eed0ef25 Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Fri, 3 Aug 2012 08:40:00 -0100 Subject: [PATCH 09/24] Updated version check code to use direct SQL statements for more flexibility. In doing so, also fixed work item 30972. --- src/SQLCE4Umbraco/SqlCEInstaller.cs | 10 +- .../SqlHelpers/MySql/MySqlInstaller.cs | 10 +- .../SqlServer/SqlServerInstaller.cs | 10 +- .../Installer/DefaultInstallerUtility.cs | 106 ++++++++---------- 4 files changed, 64 insertions(+), 72 deletions(-) diff --git a/src/SQLCE4Umbraco/SqlCEInstaller.cs b/src/SQLCE4Umbraco/SqlCEInstaller.cs index 4f85b13a2d..0d60c20288 100644 --- a/src/SQLCE4Umbraco/SqlCEInstaller.cs +++ b/src/SQLCE4Umbraco/SqlCEInstaller.cs @@ -26,11 +26,11 @@ namespace SqlCE4Umbraco /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "'FK_umbracoUser2app_umbracoApp'", false, DatabaseVersion.Version4_8), - new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), - new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), - new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), - new VersionSpecs("id","sysobjects",DatabaseVersion.None) }; + 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), + new VersionSpecs("SELECT id FROM sysobjects",DatabaseVersion.None) }; #endregion diff --git a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs index ad9892a2a5..617d1daba3 100644 --- a/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/MySql/MySqlInstaller.cs @@ -25,11 +25,11 @@ namespace umbraco.DataLayer.SqlHelpers.MySql /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "'FK_umbracoUser2app_umbracoApp'", false, DatabaseVersion.Version4_8), - new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), - new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), - new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), - new VersionSpecs("version()","",DatabaseVersion.None) }; + 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), + new VersionSpecs("SELECT version()", DatabaseVersion.None) }; #endregion diff --git a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs index 4b735e0504..74918e459b 100644 --- a/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs +++ b/src/umbraco.datalayer/SqlHelpers/SqlServer/SqlServerInstaller.cs @@ -24,11 +24,11 @@ namespace umbraco.DataLayer.SqlHelpers.SqlServer /// The specifications to determine the database version. private static readonly VersionSpecs[] m_VersionSpecs = new VersionSpecs[] { - new VersionSpecs("CONSTRAINT_NAME","INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS", "'FK_umbracoUser2app_umbracoApp'", false, DatabaseVersion.Version4_8), - new VersionSpecs("id","umbracoNode", "-21", DatabaseVersion.Version4_1), - new VersionSpecs("action","umbracoAppTree",DatabaseVersion.Version4), - new VersionSpecs("description","cmsContentType",DatabaseVersion.Version3), - new VersionSpecs("id","sysobjects",DatabaseVersion.None) }; + 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), + new VersionSpecs("SELECT id FROM sysobjects", DatabaseVersion.None) }; #endregion diff --git a/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs b/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs index 5958150166..816fc94a8d 100644 --- a/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs +++ b/src/umbraco.datalayer/Utility/Installer/DefaultInstallerUtility.cs @@ -195,17 +195,37 @@ namespace umbraco.DataLayer.Utility.Installer { try { - if (!String.IsNullOrEmpty(v.Table) && !String.IsNullOrEmpty(v.Field) && !String.IsNullOrEmpty(v.Value)) - { - IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT {0} FROM {1} WHERE {0}={2}", v.Field, v.Table, v.Value)); - var canRead = reader.Read(); - if ((v.ShouldExist && !canRead) || (!v.ShouldExist && canRead)) - continue; - } - else if (String.IsNullOrEmpty(v.Table)) - SqlHelper.ExecuteNonQuery(string.Format("SELECT {0}", v.Field)); - else - SqlHelper.ExecuteNonQuery(string.Format("SELECT {0} FROM {1}", v.Field, v.Table)); + if(v.ExpectedRows > -1) + { + var reader = SqlHelper.ExecuteReader(v.Sql); + var rowCount = 0; + + if(reader.HasRecords) + { + while (reader.Read()) + rowCount++; + } + + if (v.ExpectedRows != rowCount) + continue; + } + else + { + SqlHelper.ExecuteNonQuery(v.Sql); + } + + //if (!String.IsNullOrEmpty(v.Table) && !String.IsNullOrEmpty(v.Field) && !String.IsNullOrEmpty(v.Value)) + //{ + // IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT {0} FROM {1} WHERE {0}={2}", v.Field, v.Table, v.Value)); + // var canRead = reader.Read(); + // if ((v.ShouldExist && !canRead) || (!v.ShouldExist && canRead)) + // continue; + //} + //else if (String.IsNullOrEmpty(v.Table)) + // SqlHelper.ExecuteNonQuery(string.Format("SELECT {0}", v.Field)); + //else + // SqlHelper.ExecuteNonQuery(string.Format("SELECT {0} FROM {1}", v.Field, v.Table)); + return v.Version; } catch { } @@ -250,16 +270,11 @@ namespace umbraco.DataLayer.Utility.Installer /// public struct VersionSpecs { - /// The name of the field that should exist in order to have at least the specified version. - public readonly string Field; - /// The name of the table whose field should exist in order to have at least the specified version. - public readonly string Table; - /// - /// The value to look for in the field, if this is left empty it will not be queried. - /// - public readonly string Value; - /// Boolean flag indicating whether the value should or shouldn't exist. - public readonly bool ShouldExist; + /// The SQL statament to execute in order to test for the specified version + public readonly string Sql; + + /// An integer identifying the expected row count from the Sql statement + public readonly int ExpectedRows; /// The minimum version number of a database that contains the specified field. public readonly DatabaseVersion Version; @@ -267,46 +282,23 @@ namespace umbraco.DataLayer.Utility.Installer /// /// Initializes a new instance of the struct. /// - /// The field. - /// The table. + /// The sql statement to execute. /// The version. - public VersionSpecs(string field, string table, DatabaseVersion version) - { - Field = field; - Table = table; - Version = version; - Value = ""; - ShouldExist = true; - } + public VersionSpecs(string sql, DatabaseVersion version) + : this(sql, -1, version) + { } /// /// Initializes a new instance of the struct. - /// - /// The field. - /// The table. - /// The version. - public VersionSpecs(string field, string table, string value, DatabaseVersion version) - { - Field = field; - Table = table; - Value = value; - Version = version; - ShouldExist = true; - } - - /// - /// Initializes a new instance of the struct. /// - /// The field. - /// The table. - /// The version. - public VersionSpecs(string field, string table, string value, bool shouldExist, DatabaseVersion version) - { - Field = field; - Table = table; - Value = value; - Version = version; - ShouldExist = shouldExist; - } + /// The sql statement to execute. + /// The expected row count. + /// The version. + public VersionSpecs(string sql, int expectedRows, DatabaseVersion version) + { + Sql = sql; + ExpectedRows = expectedRows; + Version = version; + } } } From c104121ff1f8d75afc8092c389ecfea3bc899cbb Mon Sep 17 00:00:00 2001 From: Casey Neehouse Date: Tue, 7 Aug 2012 22:42:40 +0400 Subject: [PATCH 10/24] Inserting additional tracing to RazorMacroEngine Execute methods. --- .../RazorCore/RazorMacroEngine.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs b/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs index b8f46be9b2..7ea5cc9928 100644 --- a/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs +++ b/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs @@ -77,12 +77,19 @@ namespace umbraco.MacroEngines var contextWrapper = new HttpContextWrapper(context); //inject http context - for request response + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Context (file: {0})", macro.Name)); razorWebPage.Context = contextWrapper; + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Context (file: {0})", macro.Name)); //Inject Macro Model And Parameters if (razorWebPage is IMacroContext) { + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Boxing Macro Script MacroContext (file: {0})", macro.Name)); var razorMacro = (IMacroContext)razorWebPage; + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Boxing Macro Script MacroContext (file: {0})", macro.Name)); + + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Model (file: {0})", macro.Name)); razorMacro.SetMembers(macro, currentPage); + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Model (file: {0})", macro.Name)); } } @@ -106,11 +113,16 @@ namespace umbraco.MacroEngines return String.Empty; //No File Location var razorWebPage = CompileAndInstantiate(fileLocation); + + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Loading Macro Script Context (file: {0})", macro.Name)); InjectContext(razorWebPage, macro, currentPage); + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Loading Macro Script Context (file: {0})", macro.Name)); //Output Razor To String var output = new StringWriter(); + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Executing Macro Script (file: {0})", macro.Name)); razorWebPage.ExecutePageHierarchy(new WebPageContext(contextWrapper, razorWebPage, null), output); + HttpContext.Current.Trace.Write("umbracoMacro", string.Format("Done Executing Macro Script (file: {0})", macro.Name)); return output.ToString(); } From f97c171a972a076b740e5bb6e8d184f727210fbe Mon Sep 17 00:00:00 2001 From: Casey Neehouse Date: Wed, 8 Aug 2012 00:07:03 +0400 Subject: [PATCH 11/24] Changes to the GetDocumentsForExpiration method to only unpublish nodes set to published rather than newest. --- src/umbraco.cms/businesslogic/web/Document.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index 93e7d122ca..79352d52cd 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -646,7 +646,7 @@ namespace umbraco.cms.businesslogic.web { ArrayList docs = new ArrayList(); IRecordsReader dr = - SqlHelper.ExecuteReader("select distinct nodeId from cmsDocument where newest = 1 and not expireDate is null and expireDate <= @today", + SqlHelper.ExecuteReader("select distinct nodeId from cmsDocument where published = 1 and not expireDate is null and expireDate <= @today", SqlHelper.CreateParameter("@today", DateTime.Now)); while (dr.Read()) docs.Add(dr.GetInt("nodeId")); From 493e5c7734b9cda84fbc9fe95f172c020d54a62c Mon Sep 17 00:00:00 2001 From: pgregorynz Date: Tue, 7 Aug 2012 18:20:59 -1000 Subject: [PATCH 12/24] Resolve issue #30937. Fixes problem with iFileHanderData in intranet environ in IE. --- .../businesslogic/datatype/FileHandlerData.cs | 17 +++++++++++++++-- .../uploadfield/uploadField.cs | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs index 5f2262cb6e..c2ed78c2a3 100644 --- a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs +++ b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Text.RegularExpressions; using System.Web; using System.Xml; using umbraco.cms.businesslogic.Files; @@ -32,13 +33,13 @@ namespace umbraco.cms.businesslogic.datatype if (value is HttpPostedFile) { var file = value as HttpPostedFile; - name = file.FileName; + name = SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower()); fileStream = file.InputStream; } else if (value is HttpPostedFileBase) { var file = value as HttpPostedFileBase; - name = file.FileName; + name = SafeFileName(file.FileName.Substring(file.FileName.LastIndexOf(IOHelper.DirSepChar) + 1, file.FileName.Length - file.FileName.LastIndexOf(IOHelper.DirSepChar) - 1).ToLower()); fileStream = file.InputStream; } else if (value is HttpPostedFileWrapper) @@ -126,6 +127,18 @@ namespace umbraco.cms.businesslogic.datatype } } + /// + /// Check to see if filename passed has any special chars in it and strips them to create a safe filename. Used to overcome an issue when Umbraco is used in IE in an intranet environment. + /// + /// The filename passed to the file handler from the upload field. + /// A safe filename without any path specific chars. + private string SafeFileName(string filePath) + { + if (!String.IsNullOrEmpty(filePath)) + return Regex.Replace(filePath, @"[^a-zA-Z0-9\-\.\/\:]{1}", "_"); + return String.Empty; + } + private void clearRelatedValues() { string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias; diff --git a/src/umbraco.editorControls/uploadfield/uploadField.cs b/src/umbraco.editorControls/uploadfield/uploadField.cs index f974bc4787..4b57d3e78c 100644 --- a/src/umbraco.editorControls/uploadfield/uploadField.cs +++ b/src/umbraco.editorControls/uploadfield/uploadField.cs @@ -161,6 +161,7 @@ namespace umbraco.editorControls #endregion + [Obsolete("This method is now obsolete due to a change in the way that files are handled. If you need to check if a URL for an uploaded file is safe you should implement your own as this method will be removed in a future version", false)] public string SafeUrl(string url) { if (!String.IsNullOrEmpty(url)) From 39d0f95c2ebac2a79ca180b04fab588bf684e4ff Mon Sep 17 00:00:00 2001 From: hartvig Date: Thu, 9 Aug 2012 06:41:30 -0200 Subject: [PATCH 13/24] Fixes null exception issue when using 'umbracoFile' as the alias of an upload property. Work items: 30980 --- src/umbraco.cms/businesslogic/Content.cs | 4 +++- .../web.Template.UMBRACOELISE.Debug.config | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/umbraco.cms/businesslogic/Content.cs b/src/umbraco.cms/businesslogic/Content.cs index a94b6e45dc..fe7d5fdb25 100644 --- a/src/umbraco.cms/businesslogic/Content.cs +++ b/src/umbraco.cms/businesslogic/Content.cs @@ -512,6 +512,9 @@ namespace umbraco.cms.businesslogic Guid newVersion = Guid.NewGuid(); bool tempHasVersion = hasVersion(); + + // we need to ensure that a version in the db exist before we add related data + SqlHelper.ExecuteNonQuery("Insert into cmsContentVersion (ContentId,versionId) values (" + this.Id + ",'" + newVersion + "')"); foreach (propertytype.PropertyType pt in this.ContentType.PropertyTypes) { object oldValue = ""; @@ -526,7 +529,6 @@ namespace umbraco.cms.businesslogic property.Property p = this.addProperty(pt, newVersion); if (oldValue != null && oldValue.ToString() != "") p.Value = oldValue; } - SqlHelper.ExecuteNonQuery("Insert into cmsContentVersion (ContentId,versionId) values (" + this.Id + ",'" + newVersion + "')"); this.Version = newVersion; return newVersion; } diff --git a/src/umbraco.presentation/web.Template.UMBRACOELISE.Debug.config b/src/umbraco.presentation/web.Template.UMBRACOELISE.Debug.config index 4b2e4bb8da..124bf94e8e 100644 --- a/src/umbraco.presentation/web.Template.UMBRACOELISE.Debug.config +++ b/src/umbraco.presentation/web.Template.UMBRACOELISE.Debug.config @@ -17,9 +17,9 @@ + value="server=.\sqlexpress;database=481;user id=DBUSER;password=DBPASSWORD"/> + value="4.8.1"/> From 28722be34c6fd97461637ade2560da089d549b36 Mon Sep 17 00:00:00 2001 From: hartvig Date: Thu, 9 Aug 2012 07:28:55 -0200 Subject: [PATCH 14/24] Fixes issue with automatic image resizing in tinyMCE. Work items: 30963 --- .../businesslogic/Files/UmbracoFile.cs | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs b/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs index 1328eb9892..ec1d7666b4 100644 --- a/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs +++ b/src/umbraco.cms/businesslogic/Files/UmbracoFile.cs @@ -174,7 +174,7 @@ namespace umbraco.cms.businesslogic.Files string fileNameThumb = DoResize(width, height, 0, String.Empty); - return fileNameThumb.Substring(IO.IOHelper.MapPath(IO.SystemDirectories.Root).Length); + return fileNameThumb.Substring(IO.IOHelper.MapPath(IO.SystemDirectories.Root).Length-1); } public string Resize(int maxWidthHeight, string fileNameAddition) @@ -197,7 +197,7 @@ namespace umbraco.cms.businesslogic.Files string fileNameThumb = String.IsNullOrEmpty(fileNameAddition) ? string.Format("{0}_UMBRACOSYSTHUMBNAIL.jpg", _fullFilePath.Substring(0, _fullFilePath.LastIndexOf("."))) : string.Format("{0}_{1}.jpg", _fullFilePath.Substring(0, _fullFilePath.LastIndexOf(".")), fileNameAddition); - generateThumbnail( + fileNameThumb = generateThumbnail( image, maxWidthHeight, width, @@ -206,7 +206,7 @@ namespace umbraco.cms.businesslogic.Files _extension, fileNameThumb, maxWidthHeight == 0 - ); + ).FileName; image.Dispose(); return fileNameThumb; } @@ -220,7 +220,7 @@ namespace umbraco.cms.businesslogic.Files } - private System.Tuple generateThumbnail(System.Drawing.Image image, int maxWidthHeight, int fileWidth, int fileHeight, string fullFilePath, string ext, string thumbnailFileName, bool useFixedDimensions) + private ResizedImage generateThumbnail(System.Drawing.Image image, int maxWidthHeight, int fileWidth, int fileHeight, string fullFilePath, string ext, string thumbnailFileName, bool useFixedDimensions) { // Generate thumbnail float f = 1; @@ -267,14 +267,35 @@ namespace umbraco.cms.businesslogic.Files ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 90L); // Save the new image using the dimensions of the image - bp.Save(thumbnailFileName.Replace("UMBRACOSYSTHUMBNAIL", string.Format("{0}x{1}", widthTh, heightTh)), codec, ep); + string newFileName = thumbnailFileName.Replace("UMBRACOSYSTHUMBNAIL", + string.Format("{0}x{1}", widthTh, heightTh)); + bp.Save(newFileName, codec, ep); bp.Dispose(); g.Dispose(); - return new System.Tuple(widthTh, heightTh); + return new ResizedImage(widthTh, heightTh, newFileName); } } + + internal class ResizedImage + { + public ResizedImage() + { + + } + + public ResizedImage(int width, int height, string fileName) + { + Width = width; + Height = height; + FileName = fileName; + } + + public int Width { get; set; } + public int Height { get; set; } + public string FileName { get; set; } + } } From 9531a3f37a79b751af180780ab65f1a310a7100c Mon Sep 17 00:00:00 2001 From: hartvig Date: Thu, 9 Aug 2012 10:06:10 -0200 Subject: [PATCH 15/24] Updates to login cookies --- .../BasePages/BasePage.cs | 224 +++++++++++------- 1 file changed, 141 insertions(+), 83 deletions(-) diff --git a/src/umbraco.businesslogic/BasePages/BasePage.cs b/src/umbraco.businesslogic/BasePages/BasePage.cs index c5eb2ce75d..b0e367ebe0 100644 --- a/src/umbraco.businesslogic/BasePages/BasePage.cs +++ b/src/umbraco.businesslogic/BasePages/BasePage.cs @@ -2,22 +2,25 @@ using System; using System.Data; using System.Web; using System.Linq; +using System.Web.Security; using umbraco.BusinessLogic; using umbraco.DataLayer; using umbraco.IO; using System.Web.UI; -namespace umbraco.BasePages { +namespace umbraco.BasePages +{ /// /// umbraco.BasePages.BasePage is the default page type for the umbraco backend. /// The basepage keeps track of the current user and the page context. But does not /// Restrict access to the page itself. /// The keep the page secure, the umbracoEnsuredPage class should be used instead /// - public class BasePage : System.Web.UI.Page { + public class BasePage : System.Web.UI.Page + { private User _user; private bool _userisValidated = false; - private ClientTools m_clientTools; + private ClientTools m_clientTools; // ticks per minute 600,000,000 private static long _ticksPrMinute = 600000000; @@ -42,70 +45,78 @@ namespace umbraco.BasePages { /// Gets the SQL helper. /// /// The SQL helper. - protected static ISqlHelper SqlHelper { + protected static ISqlHelper SqlHelper + { get { return umbraco.BusinessLogic.Application.SqlHelper; } } /// /// Initializes a new instance of the class. /// - public BasePage() { + public BasePage() + { } - /// - /// Returns the current BasePage for the current request. - /// This assumes that the current page is a BasePage, otherwise, returns null; - /// - public static BasePage Current - { - get - { - return HttpContext.Current.CurrentHandler as BasePage; - } - } - - /// - /// Returns a refernce of an instance of ClientTools for access to the pages client API - /// - public ClientTools ClientTools - { - get - { - if (m_clientTools == null) - m_clientTools = new ClientTools(this); - return m_clientTools; - } - } - - [Obsolete("Use ClientTools instead")] - public void RefreshPage(int Seconds) - { - ClientTools.RefreshAdmin(Seconds); + /// + /// Returns the current BasePage for the current request. + /// This assumes that the current page is a BasePage, otherwise, returns null; + /// + public static BasePage Current + { + get + { + return HttpContext.Current.CurrentHandler as BasePage; + } } - private void validateUser() { - if ((umbracoUserContextID != "")) { + /// + /// Returns a refernce of an instance of ClientTools for access to the pages client API + /// + public ClientTools ClientTools + { + get + { + if (m_clientTools == null) + m_clientTools = new ClientTools(this); + return m_clientTools; + } + } + + [Obsolete("Use ClientTools instead")] + public void RefreshPage(int Seconds) + { + ClientTools.RefreshAdmin(Seconds); + } + + private void validateUser() + { + if ((umbracoUserContextID != "")) + { uid = GetUserId(umbracoUserContextID); timeout = GetTimeout(umbracoUserContextID); - if (timeout > DateTime.Now.Ticks) { + if (timeout > DateTime.Now.Ticks) + { _user = BusinessLogic.User.GetUser(uid); // Check for console access if (_user.Disabled || (_user.NoConsole && GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && !GlobalSettings.RequestIsLiveEditRedirector(HttpContext.Current))) { throw new ArgumentException("You have no priviledges to the umbraco console. Please contact your administrator"); - } + } else { _userisValidated = true; updateLogin(); } - } else { + } + else + { throw new ArgumentException("User has timed out!!"); } - } else + } + else throw new ArgumentException("The user has no umbraco contextid - try logging in"); } @@ -114,9 +125,12 @@ namespace umbraco.BasePages { /// /// The umbraco user context ID. /// - public static int GetUserId(string umbracoUserContextID) { - try { - if (System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID] == null) { + public static int GetUserId(string umbracoUserContextID) + { + try + { + if (System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID] == null) + { System.Web.HttpRuntime.Cache.Insert( "UmbracoUserContext" + umbracoUserContextID, SqlHelper.ExecuteScalar("select userID from umbracoUserLogins where contextID = @contextId", @@ -131,7 +145,9 @@ namespace umbraco.BasePages { return (int)System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID]; - } catch { + } + catch + { return -1; } } @@ -143,7 +159,8 @@ namespace umbraco.BasePages { /// /// The umbraco user context ID. /// - public static bool ValidateUserContextID(string currentUmbracoUserContextID) { + public static bool ValidateUserContextID(string currentUmbracoUserContextID) + { if ((currentUmbracoUserContextID != "")) { int uid = GetUserId(currentUmbracoUserContextID); @@ -153,14 +170,16 @@ namespace umbraco.BasePages { { return true; } - + BusinessLogic.Log.Add(BusinessLogic.LogTypes.Logout, BusinessLogic.User.GetUser(uid), -1, ""); } return false; } - private static long GetTimeout(string umbracoUserContextID) { - if (System.Web.HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID] == null) { + private static long GetTimeout(string umbracoUserContextID) + { + if (System.Web.HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID] == null) + { System.Web.HttpRuntime.Cache.Insert( "UmbracoUserContextTimeout" + umbracoUserContextID, GetTimeout(true), @@ -171,8 +190,8 @@ namespace umbraco.BasePages { } object timeout = HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID]; - if(timeout != null) - return (long) timeout; + if (timeout != null) + return (long)timeout; return 0; @@ -198,25 +217,58 @@ namespace umbraco.BasePages { /// Gets or sets the umbraco user context ID. /// /// The umbraco user context ID. - public static string umbracoUserContextID { + public static string umbracoUserContextID + { get { - // zb-00004 #29956 : refactor cookies names & handling - if (StateHelper.Cookies.HasCookies && StateHelper.Cookies.UserContext.HasValue) - return StateHelper.Cookies.UserContext.GetValue(); - else - return ""; - } - set { - // zb-00004 #29956 : refactor cookies names & handling - if (StateHelper.Cookies.HasCookies) - { - // Clearing all old cookies before setting a new one. - if (StateHelper.Cookies.UserContext.HasValue) - StateHelper.Cookies.ClearAll(); + // zb-00004 #29956 : refactor cookies names & handling + if (StateHelper.Cookies.HasCookies && StateHelper.Cookies.UserContext.HasValue) + { + try + { + string encTicket = StateHelper.Cookies.UserContext.GetValue(); + if (!String.IsNullOrEmpty(encTicket)) + return FormsAuthentication.Decrypt(encTicket).UserData; + } + catch (HttpException ex) + { + // we swallow this type of exception as it happens if a legacy (pre 4.8.1) cookie is set + } + } - // Create new cookie. - StateHelper.Cookies.UserContext.SetValue(value, 1); + return ""; + } + set + { + // zb-00004 #29956 : refactor cookies names & handling + if (StateHelper.Cookies.HasCookies) + { + // Clearing all old cookies before setting a new one. + if (StateHelper.Cookies.UserContext.HasValue) + StateHelper.Cookies.ClearAll(); + + if (!String.IsNullOrEmpty(value)) + { + FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, + value, + DateTime.Now, + DateTime.Now.AddDays(1), + false, + value, + FormsAuthentication.FormsCookiePath); + + // Encrypt the ticket. + string encTicket = FormsAuthentication.Encrypt(ticket); + + + // Create new cookie. + StateHelper.Cookies.UserContext.SetValue(encTicket, 1); + + + } else + { + StateHelper.Cookies.UserContext.Clear(); + } } } } @@ -261,7 +313,8 @@ namespace umbraco.BasePages { /// Logs a user in. /// /// The user - public static void doLogin(User u) { + public static void doLogin(User u) + { Guid retVal = Guid.NewGuid(); SqlHelper.ExecuteNonQuery( "insert into umbracoUserLogins (contextID, userID, timeout) values (@contextId,'" + u.Id + "','" + @@ -277,7 +330,8 @@ namespace umbraco.BasePages { /// Gets the user. /// /// - public User getUser() { + public User getUser() + { if (!_userisValidated) validateUser(); return _user; } @@ -285,26 +339,28 @@ namespace umbraco.BasePages { /// /// Ensures the page context. /// - public void ensureContext() { + public void ensureContext() + { validateUser(); } - - [Obsolete("Use ClientTools instead")] - public void speechBubble(speechBubbleIcon i, string header, string body) - { - ClientTools.ShowSpeechBubble(i, header, body); + + [Obsolete("Use ClientTools instead")] + public void speechBubble(speechBubbleIcon i, string header, string body) + { + ClientTools.ShowSpeechBubble(i, header, body); } - //[Obsolete("Use ClientTools instead")] - //public void reloadParentNode() - //{ - // ClientTools.ReloadParentNode(true); - //} + //[Obsolete("Use ClientTools instead")] + //public void reloadParentNode() + //{ + // ClientTools.ReloadParentNode(true); + //} /// /// a collection of available speechbubble icons /// - public enum speechBubbleIcon { + public enum speechBubbleIcon + { /// /// Save icon /// @@ -331,10 +387,12 @@ namespace umbraco.BasePages { /// Raises the event. /// /// The object that contains the event data. - protected override void OnLoad(EventArgs e) { + protected override void OnLoad(EventArgs e) + { base.OnLoad(e); - - if (!Request.IsSecureConnection && GlobalSettings.UseSSL) { + + if (!Request.IsSecureConnection && GlobalSettings.UseSSL) + { string serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]); Response.Redirect(string.Format("https://{0}{1}", serverName, Request.FilePath)); } From bb4f4822d4d34a65bc0dbdb0e3a6cfed72d8488a Mon Sep 17 00:00:00 2001 From: hartvig Date: Thu, 9 Aug 2012 10:27:34 -0200 Subject: [PATCH 16/24] Fixes issue with images with a filename that has dimensions appended (ie. myimage_300x200.jpg) inserted into tinyMCE. Work items: 30864 --- .../tinyMCE3/webcontrol/TinyMCEWebControl.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs b/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs index 770239a15e..b386ef6a51 100644 --- a/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs +++ b/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs @@ -326,10 +326,9 @@ namespace umbraco.editorControls.tinyMCE3.webcontrol tempTag += " " + ide.Key.ToString() + "=\"" + ide.Value.ToString() + "\""; // Find the original filename, by removing the might added width and height + // NH, 4.8.1 - above replaced by loading the right media file from the db later! orgSrc = - IOHelper.ResolveUrl(orgSrc.Replace( - "_" + helper.FindAttribute(ht, "width") + "x" + helper.FindAttribute(ht, "height"), ""). - Replace("%20", " ")); + IOHelper.ResolveUrl(orgSrc.Replace("%20", " ")); // Check for either id or guid from media string mediaId = getIdFromSource(orgSrc, localMediaPath); @@ -358,15 +357,10 @@ namespace umbraco.editorControls.tinyMCE3.webcontrol { try { - // Check extention - if (imageMedia.getProperty("umbracoExtension").Value.ToString() != orgSrc.Substring(orgSrc.LastIndexOf(".") + 1, orgSrc.Length - orgSrc.LastIndexOf(".") - 1)) - orgSrc = orgSrc.Substring(0, orgSrc.LastIndexOf(".") + 1) + - imageMedia.getProperty("umbracoExtension").Value.ToString(); - // Format the tag tempTag = tempTag + " rel=\"" + imageMedia.getProperty("umbracoWidth").Value.ToString() + "," + - imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + orgSrc + + imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + IOHelper.ResolveUrl(imageMedia.getProperty("umbracoFile").Value.ToString()) + "\""; tempTag += "/>"; From 3acfb2a9eacf0458d854d8f7d9895b1c80098fe7 Mon Sep 17 00:00:00 2001 From: hartvig Date: Thu, 9 Aug 2012 11:15:55 -0200 Subject: [PATCH 17/24] Updates to login cookies --- src/umbraco.businesslogic/BasePages/BasePage.cs | 6 ++++++ src/umbraco.businesslogic/StateHelper.cs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/umbraco.businesslogic/BasePages/BasePage.cs b/src/umbraco.businesslogic/BasePages/BasePage.cs index b0e367ebe0..7964fbad22 100644 --- a/src/umbraco.businesslogic/BasePages/BasePage.cs +++ b/src/umbraco.businesslogic/BasePages/BasePage.cs @@ -234,6 +234,12 @@ namespace umbraco.BasePages { // we swallow this type of exception as it happens if a legacy (pre 4.8.1) cookie is set } + catch (ArgumentException ex) + { + // we swallow this one because it's 99.99% certaincy is legacy based. We'll still log it, though + Log.Instance.AddException(ex); + + } } return ""; diff --git a/src/umbraco.businesslogic/StateHelper.cs b/src/umbraco.businesslogic/StateHelper.cs index 10103cffdb..4d5ab3ff17 100644 --- a/src/umbraco.businesslogic/StateHelper.cs +++ b/src/umbraco.businesslogic/StateHelper.cs @@ -354,6 +354,8 @@ namespace umbraco.BusinessLogic public void SetValue(string value) { HttpCookie cookie = new HttpCookie(_key, value); + if (GlobalSettings.UseSSL) + cookie.Secure = true; if (!TimeSpan.Zero.Equals(_expires)) cookie.Expires = DateTime.Now + _expires; ResponseCookie = cookie; @@ -378,7 +380,9 @@ namespace umbraco.BusinessLogic public void SetValue(string value, DateTime expires) { HttpCookie cookie = new HttpCookie(_key, value); - cookie.Expires = expires; + if (GlobalSettings.UseSSL) + cookie.Secure = true; + cookie.Expires = expires; ResponseCookie = cookie; // original Umbraco code also does this From c4214a7ee9ca41cc09652b65a0340ed67dc1cedd Mon Sep 17 00:00:00 2001 From: sebastiaan Date: Thu, 9 Aug 2012 14:04:49 -0200 Subject: [PATCH 18/24] The version header is no longer needed and a potential attack vector. Has now been removed - Work item: 30989 --- src/umbraco.businesslogic/UmbracoSettings.cs | 22 ------------------- .../config/umbracoSettings.Release.config | 2 -- src/umbraco.presentation/default.aspx.cs | 4 ---- 3 files changed, 28 deletions(-) diff --git a/src/umbraco.businesslogic/UmbracoSettings.cs b/src/umbraco.businesslogic/UmbracoSettings.cs index f032f89fd3..7a38b42823 100644 --- a/src/umbraco.businesslogic/UmbracoSettings.cs +++ b/src/umbraco.businesslogic/UmbracoSettings.cs @@ -311,28 +311,6 @@ namespace umbraco } } - /// - /// Gets a value indicating whether umbraco shouldn't add X-Umbraco-Version to the http header. - /// - /// true if umbraco will not add header; otherwise, false. - public static bool RemoveUmbracoVersionHeader - { - get - { - try - { - bool result; - if (bool.TryParse(GetKey("/settings/requestHandler/removeUmbracoVersionHeader"), out result)) - return result; - return false; - } - catch - { - return false; - } - } - } - /// /// This will add a trailing slash (/) to urls when in directory url mode /// NOTICE: This will always return false if Directory Urls in not active diff --git a/src/umbraco.presentation/config/umbracoSettings.Release.config b/src/umbraco.presentation/config/umbracoSettings.Release.config index 9b36698f97..dae69d2df4 100644 --- a/src/umbraco.presentation/config/umbracoSettings.Release.config +++ b/src/umbraco.presentation/config/umbracoSettings.Release.config @@ -124,8 +124,6 @@ ae oe - - false diff --git a/src/umbraco.presentation/default.aspx.cs b/src/umbraco.presentation/default.aspx.cs index 53b4b19dc1..b18e10c58a 100644 --- a/src/umbraco.presentation/default.aspx.cs +++ b/src/umbraco.presentation/default.aspx.cs @@ -206,10 +206,6 @@ namespace umbraco if (!UmbracoSettings.UseAspNetMasterPages) initUmbracoPage(); base.OnInit(e); - - // Add Umbraco header - if (!UmbracoSettings.RemoveUmbracoVersionHeader) - Response.AddHeader("X-Umbraco-Version", string.Format("{0}.{1}", GlobalSettings.VersionMajor, GlobalSettings.VersionMinor)); } private void initUmbracoPage() From a79d11aad70ea2f932fbcfe22f33fd3485327644 Mon Sep 17 00:00:00 2001 From: sebastiaan Date: Sat, 11 Aug 2012 05:55:26 -0200 Subject: [PATCH 19/24] Fix for workitem 30993 - When RTE context menu is disabled, the RTE fails to show --- .../umbracocontextmenu/editor_plugin_src.js | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/umbraco.presentation/umbraco_client/tinymce3/plugins/umbracocontextmenu/editor_plugin_src.js b/src/umbraco.presentation/umbraco_client/tinymce3/plugins/umbracocontextmenu/editor_plugin_src.js index da22f21a87..3d8ccfad4b 100644 --- a/src/umbraco.presentation/umbraco_client/tinymce3/plugins/umbracocontextmenu/editor_plugin_src.js +++ b/src/umbraco.presentation/umbraco_client/tinymce3/plugins/umbracocontextmenu/editor_plugin_src.js @@ -26,42 +26,40 @@ * @param {string} url Absolute URL to where the plugin is located. */ init: function (ed) { - var t = this; - - ed.plugins.contextmenu.onContextMenu.add(function (th, menu, event) { - - var keys = UmbClientMgr.uiKeys(); - - $.each(menu.items, function (idx, el) { + if (ed.plugins.contextmenu) { - switch (el.settings.cmd) { - case "Cut": - el.settings.title = keys['defaultdialogs_cut']; - break; - case "Copy": - el.settings.title = keys['general_copy']; - break; - case "Paste": - el.settings.title = keys['defaultdialogs_paste']; - break; - case "mceAdvLink": - case "mceLink": - el.settings.title = keys['defaultdialogs_insertlink']; - break; - case "UnLink": - el.settings.title = keys['relatedlinks_removeLink']; - break; - case "mceImage": - el.settings.title = keys['defaultdialogs_insertimage']; - el.settings.cmd = "mceUmbimage"; - break; - } + ed.plugins.contextmenu.onContextMenu.add(function (th, menu, event) { + var keys = UmbClientMgr.uiKeys(); + + $.each(menu.items, function (idx, el) { + + switch (el.settings.cmd) { + case "Cut": + el.settings.title = keys['defaultdialogs_cut']; + break; + case "Copy": + el.settings.title = keys['general_copy']; + break; + case "Paste": + el.settings.title = keys['defaultdialogs_paste']; + break; + case "mceAdvLink": + case "mceLink": + el.settings.title = keys['defaultdialogs_insertlink']; + break; + case "UnLink": + el.settings.title = keys['relatedlinks_removeLink']; + break; + case "mceImage": + el.settings.title = keys['defaultdialogs_insertimage']; + el.settings.cmd = "mceUmbimage"; + break; + } + }); }); - - }); + } } - }); // Register plugin From 26671a405c5868aa392f4c3de5757d7a1db5038b Mon Sep 17 00:00:00 2001 From: sebastiaan Date: Mon, 13 Aug 2012 08:18:52 -0200 Subject: [PATCH 20/24] Refactor cookies SetValue to use just ONE method to set the value and expiration. Prevents us from forgetting to update the duplicate code. --- src/umbraco.businesslogic/StateHelper.cs | 516 +++++++++++------------ 1 file changed, 256 insertions(+), 260 deletions(-) diff --git a/src/umbraco.businesslogic/StateHelper.cs b/src/umbraco.businesslogic/StateHelper.cs index 4d5ab3ff17..d2f78e8ed9 100644 --- a/src/umbraco.businesslogic/StateHelper.cs +++ b/src/umbraco.businesslogic/StateHelper.cs @@ -8,9 +8,9 @@ namespace umbraco.BusinessLogic /// /// The StateHelper class provides general helper methods for handling sessions, context, viewstate and cookies. /// - public class StateHelper - { - #region Session Helpers + public class StateHelper + { + #region Session Helpers /// /// Gets the session value. @@ -18,10 +18,10 @@ namespace umbraco.BusinessLogic /// /// The key. /// - public static T GetSessionValue(string key) - { - return GetSessionValue(HttpContext.Current, key); - } + public static T GetSessionValue(string key) + { + return GetSessionValue(HttpContext.Current, key); + } /// /// Gets the session value. @@ -30,25 +30,25 @@ namespace umbraco.BusinessLogic /// The context. /// The key. /// - public static T GetSessionValue(HttpContext context, string key) - { - if (context == null) - return default(T); - object o = context.Session[key]; - if (o == null) - return default(T); - return (T)o; - } + public static T GetSessionValue(HttpContext context, string key) + { + if (context == null) + return default(T); + object o = context.Session[key]; + if (o == null) + return default(T); + return (T)o; + } /// /// Sets a session value. /// /// The key. /// The value. - public static void SetSessionValue(string key, object value) - { - SetSessionValue(HttpContext.Current, key, value); - } + public static void SetSessionValue(string key, object value) + { + SetSessionValue(HttpContext.Current, key, value); + } /// /// Sets the session value. @@ -56,16 +56,16 @@ namespace umbraco.BusinessLogic /// The context. /// The key. /// The value. - public static void SetSessionValue(HttpContext context, string key, object value) - { - if (context == null) - return; - context.Session[key] = value; - } + public static void SetSessionValue(HttpContext context, string key, object value) + { + if (context == null) + return; + context.Session[key] = value; + } - #endregion + #endregion - #region Context Helpers + #region Context Helpers /// /// Gets the context value. @@ -73,10 +73,10 @@ namespace umbraco.BusinessLogic /// /// The key. /// - public static T GetContextValue(string key) - { - return GetContextValue(HttpContext.Current, key); - } + public static T GetContextValue(string key) + { + return GetContextValue(HttpContext.Current, key); + } /// /// Gets the context value. @@ -85,25 +85,25 @@ namespace umbraco.BusinessLogic /// The context. /// The key. /// - public static T GetContextValue(HttpContext context, string key) - { - if (context == null) - return default(T); - object o = context.Items[key]; - if (o == null) - return default(T); - return (T)o; - } + public static T GetContextValue(HttpContext context, string key) + { + if (context == null) + return default(T); + object o = context.Items[key]; + if (o == null) + return default(T); + return (T)o; + } /// /// Sets the context value. /// /// The key. /// The value. - public static void SetContextValue(string key, object value) - { - SetContextValue(HttpContext.Current, key, value); - } + public static void SetContextValue(string key, object value) + { + SetContextValue(HttpContext.Current, key, value); + } /// /// Sets the context value. @@ -111,37 +111,37 @@ namespace umbraco.BusinessLogic /// The context. /// The key. /// The value. - public static void SetContextValue(HttpContext context, string key, object value) - { - if (context == null) - return; - context.Items[key] = value; - } + public static void SetContextValue(HttpContext context, string key, object value) + { + if (context == null) + return; + context.Items[key] = value; + } - #endregion + #endregion - #region ViewState Helpers + #region ViewState Helpers /// /// Gets the state bag. /// /// - private static StateBag GetStateBag() - { - if (HttpContext.Current == null) - return null; + private static StateBag GetStateBag() + { + if (HttpContext.Current == null) + return null; - Page page = HttpContext.Current.CurrentHandler as Page; - if (page == null) - return null; + Page page = HttpContext.Current.CurrentHandler as Page; + if (page == null) + return null; - Type pageType = typeof(Page); - PropertyInfo viewState = pageType.GetProperty("ViewState", BindingFlags.GetProperty | BindingFlags.Instance); - if (viewState == null) - return null; + Type pageType = typeof(Page); + PropertyInfo viewState = pageType.GetProperty("ViewState", BindingFlags.GetProperty | BindingFlags.Instance); + if (viewState == null) + return null; - return viewState.GetValue(page, null) as StateBag; - } + return viewState.GetValue(page, null) as StateBag; + } /// /// Gets the view state value. @@ -149,10 +149,10 @@ namespace umbraco.BusinessLogic /// /// The key. /// - public static T GetViewStateValue(string key) - { - return GetViewStateValue(GetStateBag(), key); - } + public static T GetViewStateValue(string key) + { + return GetViewStateValue(GetStateBag(), key); + } /// /// Gets a view-state value. @@ -161,25 +161,25 @@ namespace umbraco.BusinessLogic /// The bag. /// The key. /// - public static T GetViewStateValue(StateBag bag, string key) - { - if (bag == null) - return default(T); - object o = bag[key]; - if (o == null) - return default(T); - return (T)o; - } + public static T GetViewStateValue(StateBag bag, string key) + { + if (bag == null) + return default(T); + object o = bag[key]; + if (o == null) + return default(T); + return (T)o; + } /// /// Sets the view state value. /// /// The key. /// The value. - public static void SetViewStateValue(string key, object value) - { - SetViewStateValue(GetStateBag(), key, value); - } + public static void SetViewStateValue(string key, object value) + { + SetViewStateValue(GetStateBag(), key, value); + } /// /// Sets the view state value. @@ -187,15 +187,15 @@ namespace umbraco.BusinessLogic /// The bag. /// The key. /// The value. - public static void SetViewStateValue(StateBag bag, string key, object value) - { - if (bag != null) - bag[key] = value; - } + public static void SetViewStateValue(StateBag bag, string key, object value) + { + if (bag != null) + bag[key] = value; + } - #endregion + #endregion - #region Cookie Helpers + #region Cookie Helpers /// /// Determines whether a cookie has a value with a specified key. @@ -217,13 +217,13 @@ namespace umbraco.BusinessLogic /// /// The key. /// - public static string GetCookieValue(string key) - { - if (!Cookies.HasCookies) - return null; - var cookie = HttpContext.Current.Request.Cookies[key]; - return cookie == null ? null : cookie.Value; - } + public static string GetCookieValue(string key) + { + if (!Cookies.HasCookies) + return null; + var cookie = HttpContext.Current.Request.Cookies[key]; + return cookie == null ? null : cookie.Value; + } /// /// Sets the cookie value. @@ -232,7 +232,7 @@ namespace umbraco.BusinessLogic /// The value. public static void SetCookieValue(string key, string value) { - SetCookieValue(key, value, 30d); // default Umbraco expires is 30 days + SetCookieValue(key, value, 30d); // default Umbraco expires is 30 days } /// @@ -243,196 +243,192 @@ namespace umbraco.BusinessLogic /// How long the cookie should be present in the browser public static void SetCookieValue(string key, string value, double daysToPersist) { - if (!Cookies.HasCookies) - return; - var context = HttpContext.Current; + if (!Cookies.HasCookies) + return; + var context = HttpContext.Current; - HttpCookie cookie = new HttpCookie(key, value); - cookie.Expires = DateTime.Now.AddDays(daysToPersist); - context.Response.Cookies.Set(cookie); + HttpCookie cookie = new HttpCookie(key, value); + cookie.Expires = DateTime.Now.AddDays(daysToPersist); + context.Response.Cookies.Set(cookie); - cookie = context.Request.Cookies[key]; - if (cookie != null) - cookie.Value = value; - } + cookie = context.Request.Cookies[key]; + if (cookie != null) + cookie.Value = value; + } - // zb-00004 #29956 : refactor cookies names & handling - public static class Cookies - { - /* - * helper class to manage cookies - * - * beware! SetValue(string value) does _not_ set expires, unless the cookie has been - * configured to have one. This allows us to have cookies w/out an expires timespan. - * However, default behavior in Umbraco was to set expires to 30days by default. This - * must now be managed in the Cookie constructor or by using an overriden SetValue(...). - * - * we currently reproduce this by configuring each cookie with a 30d expires, but does - * that actually make sense? shouldn't some cookie have _no_ expires? - */ - static readonly Cookie _preview = new Cookie("UMB_PREVIEW", 30d); // was "PreviewSet" - static readonly Cookie _userContext = new Cookie("UMB_UCONTEXT", 30d); // was "UserContext" - static readonly Cookie _member = new Cookie("UMB_MEMBER", 30d); // was "umbracoMember" + // zb-00004 #29956 : refactor cookies names & handling + public static class Cookies + { + /* + * helper class to manage cookies + * + * beware! SetValue(string value) does _not_ set expires, unless the cookie has been + * configured to have one. This allows us to have cookies w/out an expires timespan. + * However, default behavior in Umbraco was to set expires to 30days by default. This + * must now be managed in the Cookie constructor or by using an overriden SetValue(...). + * + * we currently reproduce this by configuring each cookie with a 30d expires, but does + * that actually make sense? shouldn't some cookie have _no_ expires? + */ + static readonly Cookie _preview = new Cookie("UMB_PREVIEW", 30d); // was "PreviewSet" + static readonly Cookie _userContext = new Cookie("UMB_UCONTEXT", 30d); // was "UserContext" + static readonly Cookie _member = new Cookie("UMB_MEMBER", 30d); // was "umbracoMember" - public static Cookie Preview { get { return _preview; } } - public static Cookie UserContext { get { return _userContext; } } - public static Cookie Member { get { return _member; } } + public static Cookie Preview { get { return _preview; } } + public static Cookie UserContext { get { return _userContext; } } + public static Cookie Member { get { return _member; } } - public static bool HasCookies - { - get - { - System.Web.HttpContext context = HttpContext.Current; - // although just checking context should be enough?! - // but in some (replaced) umbraco code, everything is checked... - return context != null - && context.Request != null & context.Request.Cookies != null - && context.Response != null && context.Response.Cookies != null; - } - } + public static bool HasCookies + { + get + { + System.Web.HttpContext context = HttpContext.Current; + // although just checking context should be enough?! + // but in some (replaced) umbraco code, everything is checked... + return context != null + && context.Request != null & context.Request.Cookies != null + && context.Response != null && context.Response.Cookies != null; + } + } - public static void ClearAll() - { - HttpContext.Current.Response.Cookies.Clear(); - } + public static void ClearAll() + { + HttpContext.Current.Response.Cookies.Clear(); + } - public class Cookie - { - const string cookiesExtensionConfigKey = "umbracoCookiesExtension"; + public class Cookie + { + const string cookiesExtensionConfigKey = "umbracoCookiesExtension"; - static readonly string _ext; - TimeSpan _expires; - string _key; + static readonly string _ext; + TimeSpan _expires; + string _key; - static Cookie() - { - var appSettings = System.Configuration.ConfigurationManager.AppSettings; - _ext = appSettings[cookiesExtensionConfigKey] == null ? "" : "_" + (string)appSettings[cookiesExtensionConfigKey]; - } + static Cookie() + { + var appSettings = System.Configuration.ConfigurationManager.AppSettings; + _ext = appSettings[cookiesExtensionConfigKey] == null ? "" : "_" + (string)appSettings[cookiesExtensionConfigKey]; + } - public Cookie(string key) - : this(key, TimeSpan.Zero, true) - { } + public Cookie(string key) + : this(key, TimeSpan.Zero, true) + { } - public Cookie(string key, double days) - : this(key, TimeSpan.FromDays(days), true) - { } + public Cookie(string key, double days) + : this(key, TimeSpan.FromDays(days), true) + { } - public Cookie(string key, TimeSpan expires) - : this(key, expires, true) - { } + public Cookie(string key, TimeSpan expires) + : this(key, expires, true) + { } - public Cookie(string key, bool appendExtension) - : this(key, TimeSpan.Zero, appendExtension) - { } + public Cookie(string key, bool appendExtension) + : this(key, TimeSpan.Zero, appendExtension) + { } - public Cookie(string key, double days, bool appendExtension) - : this(key, TimeSpan.FromDays(days), appendExtension) - { } + public Cookie(string key, double days, bool appendExtension) + : this(key, TimeSpan.FromDays(days), appendExtension) + { } - public Cookie(string key, TimeSpan expires, bool appendExtension) - { - _key = appendExtension ? key + _ext : key; - _expires = expires; - } + public Cookie(string key, TimeSpan expires, bool appendExtension) + { + _key = appendExtension ? key + _ext : key; + _expires = expires; + } - public string Key - { - get { return _key; } - } + public string Key + { + get { return _key; } + } - public bool HasValue - { - get { return RequestCookie != null; } - } + public bool HasValue + { + get { return RequestCookie != null; } + } - public string GetValue() - { - return RequestCookie == null ? null : RequestCookie.Value; - } + public string GetValue() + { + return RequestCookie == null ? null : RequestCookie.Value; + } + + public void SetValue(string value) + { + SetValueWithDate(value, DateTime.Now + _expires); + } + + public void SetValue(string value, double days) + { + SetValue(value, DateTime.Now.AddDays(days)); + } + + public void SetValue(string value, TimeSpan expires) + { + SetValue(value, DateTime.Now + expires); + } + + public void SetValue(string value, DateTime expires) + { + SetValueWithDate(value, expires); + } + + private void SetValueWithDate(string value, DateTime expires) + { + HttpCookie cookie = new HttpCookie(_key, value); - public void SetValue(string value) - { - HttpCookie cookie = new HttpCookie(_key, value); if (GlobalSettings.UseSSL) cookie.Secure = true; - if (!TimeSpan.Zero.Equals(_expires)) - cookie.Expires = DateTime.Now + _expires; - ResponseCookie = cookie; - // original Umbraco code also does this - // so we can GetValue() back what we previously set - cookie = RequestCookie; - if (cookie != null) - cookie.Value = value; - } - - public void SetValue(string value, double days) - { - SetValue(value, DateTime.Now.AddDays(days)); - } - - public void SetValue(string value, TimeSpan expires) - { - SetValue(value, DateTime.Now + expires); - } - - public void SetValue(string value, DateTime expires) - { - HttpCookie cookie = new HttpCookie(_key, value); - if (GlobalSettings.UseSSL) - cookie.Secure = true; cookie.Expires = expires; - ResponseCookie = cookie; + ResponseCookie = cookie; - // original Umbraco code also does this - // so we can GetValue() back what we previously set - cookie = RequestCookie; - if (cookie != null) - cookie.Value = value; - } + // original Umbraco code also does this + // so we can GetValue() back what we previously set + cookie = RequestCookie; + if (cookie != null) + cookie.Value = value; + } - public void Clear() - { - if (RequestCookie != null || ResponseCookie != null) - { - HttpCookie cookie = new HttpCookie(_key); - cookie.Expires = DateTime.Now.AddDays(-1); - ResponseCookie = cookie; - } - } + public void Clear() + { + if (RequestCookie != null || ResponseCookie != null) + { + HttpCookie cookie = new HttpCookie(_key); + cookie.Expires = DateTime.Now.AddDays(-1); + ResponseCookie = cookie; + } + } - public void Remove() - { - // beware! will not clear browser's cookie - // you probably want to use .Clear() - HttpContext.Current.Response.Cookies.Remove(_key); - } + public void Remove() + { + // beware! will not clear browser's cookie + // you probably want to use .Clear() + HttpContext.Current.Response.Cookies.Remove(_key); + } - public HttpCookie RequestCookie - { - get - { - return HttpContext.Current.Request.Cookies[_key]; - } - } + public HttpCookie RequestCookie + { + get + { + return HttpContext.Current.Request.Cookies[_key]; + } + } - public HttpCookie ResponseCookie - { - get - { - return HttpContext.Current.Response.Cookies[_key]; - } - set - { - // .Set() ensures the uniqueness of cookies in the cookie collection - // ie it is the same as .Remove() + .Add() -- .Add() allows duplicates - HttpContext.Current.Response.Cookies.Set(value); - } - } - } - } + public HttpCookie ResponseCookie + { + get + { + return HttpContext.Current.Response.Cookies[_key]; + } + set + { + // .Set() ensures the uniqueness of cookies in the cookie collection + // ie it is the same as .Remove() + .Add() -- .Add() allows duplicates + HttpContext.Current.Response.Cookies.Set(value); + } + } + } + } #endregion - } + } } From d15cc4308a25fa1e2907fb5d2e62f1376aca8fda Mon Sep 17 00:00:00 2001 From: pgregorynz Date: Mon, 13 Aug 2012 20:33:34 -1000 Subject: [PATCH 21/24] Fix issue with being able to move content outside media root when media root set for user. --- .../umbraco.presentation.csproj | 6 +- .../umbraco/Trees/BaseMediaTree.cs | 103 ++++++++++-------- .../umbraco/Trees/loadMedia.cs | 63 +++++++++-- ...web.Template.PeterGregory-PC.Debug.config} | 10 +- src/umbraco.presentation/web.config | 10 +- 5 files changed, 127 insertions(+), 65 deletions(-) rename src/umbraco.presentation/{web.Template.PETER-PC.Debug.config => web.Template.PeterGregory-PC.Debug.config} (78%) diff --git a/src/umbraco.presentation/umbraco.presentation.csproj b/src/umbraco.presentation/umbraco.presentation.csproj index 7ce280ef2b..4d8fbbe71c 100644 --- a/src/umbraco.presentation/umbraco.presentation.csproj +++ b/src/umbraco.presentation/umbraco.presentation.csproj @@ -3313,9 +3313,6 @@ Web.Template.config - - Web.Template.config - Web.Template.config @@ -3346,6 +3343,9 @@ Web.Template.config + + Web.Template.config + diff --git a/src/umbraco.presentation/umbraco/Trees/BaseMediaTree.cs b/src/umbraco.presentation/umbraco/Trees/BaseMediaTree.cs index 928223af6e..97ffff30d4 100644 --- a/src/umbraco.presentation/umbraco/Trees/BaseMediaTree.cs +++ b/src/umbraco.presentation/umbraco/Trees/BaseMediaTree.cs @@ -61,54 +61,9 @@ function openMedia(id) { foreach (Media dd in docs) { - XmlTreeNode xNode = XmlTreeNode.Create(this); - xNode.NodeID = dd.Id.ToString(); - xNode.Text = dd.Text; - - // Check for dialog behaviour - if (!this.IsDialog) - { - if (!this.ShowContextMenu) - xNode.Menu = null; - xNode.Action = "javascript:openMedia(" + dd.Id + ");"; - } - else - { - if (this.ShowContextMenu) - xNode.Menu = new List(new IAction[] { ActionRefresh.Instance }); - else - xNode.Menu = null; - if (this.DialogMode == TreeDialogModes.fulllink) - { - string nodeLink = GetLinkValue(dd, dd.Id.ToString()); - if (!String.IsNullOrEmpty(nodeLink)) - { - xNode.Action = "javascript:openMedia('" + nodeLink + "');"; - } - else - { - xNode.Action = null; - xNode.DimNode(); - } - } - else - { - xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');"; - } - } - - xNode.HasChildren = dd.HasChildren; - if (this.IsDialog) - xNode.Source = GetTreeDialogUrl(dd.Id); - else - xNode.Source = GetTreeServiceUrl(dd.Id); - - if (dd.ContentType != null) - { - xNode.Icon = dd.ContentType.IconUrl; - xNode.OpenIcon = dd.ContentType.IconUrl; - } + XmlTreeNode xNode = CreateNode(dd); + OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty); if (xNode != null) { @@ -142,6 +97,60 @@ function openMedia(id) { return ""; } + protected XmlTreeNode CreateNode(Media dd) + { + + XmlTreeNode xNode = XmlTreeNode.Create(this); + xNode.NodeID = dd.Id.ToString(); + xNode.Text = dd.Text; + + // Check for dialog behaviour + if (!this.IsDialog) + { + if (!this.ShowContextMenu) + xNode.Menu = null; + xNode.Action = "javascript:openMedia(" + dd.Id + ");"; + } + else + { + if (this.ShowContextMenu) + xNode.Menu = new List(new IAction[] { ActionRefresh.Instance }); + else + xNode.Menu = null; + if (this.DialogMode == TreeDialogModes.fulllink) + { + string nodeLink = GetLinkValue(dd, dd.Id.ToString()); + if (!String.IsNullOrEmpty(nodeLink)) + { + xNode.Action = "javascript:openMedia('" + nodeLink + "');"; + } + else + { + xNode.Action = null; + xNode.DimNode(); + } + } + else + { + xNode.Action = "javascript:openMedia('" + dd.Id.ToString() + "');"; + } + } + + xNode.HasChildren = dd.HasChildren; + if (this.IsDialog) + xNode.Source = GetTreeDialogUrl(dd.Id); + else + xNode.Source = GetTreeServiceUrl(dd.Id); + + if (dd.ContentType != null) + { + xNode.Icon = dd.ContentType.IconUrl; + xNode.OpenIcon = dd.ContentType.IconUrl; + } + + return xNode; + } + /// /// By default, any media type that is to be "linkable" in the WYSIWYG editor must contain /// a DataTypeUploadField data type which will ouput the value for the link, however, if diff --git a/src/umbraco.presentation/umbraco/Trees/loadMedia.cs b/src/umbraco.presentation/umbraco/Trees/loadMedia.cs index ee9762d2b4..2a92e8dcc8 100644 --- a/src/umbraco.presentation/umbraco/Trees/loadMedia.cs +++ b/src/umbraco.presentation/umbraco/Trees/loadMedia.cs @@ -31,7 +31,7 @@ namespace umbraco [Tree("media", "media", "Media")] public class loadMedia : BaseMediaTree { - + private Media m_media; private int _StartNodeID; /// /// Create the linkable data types list and add the DataTypeUploadField guid to it. @@ -52,15 +52,64 @@ namespace umbraco : base(application) { _StartNodeID = CurrentUser.StartMediaId; - } + } + + + /// + /// Returns the Document object of the starting node for the current User. This ensures + /// that the Document object is only instantiated once. + /// + protected Media StartNode + { + get + { + if (m_media == null) + { + m_media = new Media(StartNodeID); + } + + if (!m_media.Path.Contains(CurrentUser.StartMediaId.ToString())) + { + var media = new Media(CurrentUser.StartMediaId); + if (!string.IsNullOrEmpty(media.Path) && media.Path.Contains(this.StartNodeID.ToString())) + { + m_media = media; + } + else + { + return null; + } + } + + return m_media; + } + } protected override void CreateRootNode(ref XmlTreeNode rootNode) - { - - if (this.IsDialog) - rootNode.Action = "javascript:openMedia(-1);"; + { + if (StartNodeID != -1) + { + Media doc = StartNode; + if (doc == null) + { + rootNode = new NullTree(this.app).RootNode; + rootNode.Text = "You do not have permission for this content tree"; + rootNode.HasChildren = false; + rootNode.Source = string.Empty; + } + else + { + rootNode = CreateNode(doc); + } + } else - rootNode.Action = "javascript:" + ClientTools.Scripts.OpenDashboard("Media"); + { + if (this.IsDialog) + rootNode.Action = "javascript:openMedia(-1);"; + else + rootNode.Action = "javascript:" + ClientTools.Scripts.OpenDashboard("Media"); + } + } protected override void CreateRootNodeActions(ref List actions) diff --git a/src/umbraco.presentation/web.Template.PETER-PC.Debug.config b/src/umbraco.presentation/web.Template.PeterGregory-PC.Debug.config similarity index 78% rename from src/umbraco.presentation/web.Template.PETER-PC.Debug.config rename to src/umbraco.presentation/web.Template.PeterGregory-PC.Debug.config index cab18ec4b8..34466b5f80 100644 --- a/src/umbraco.presentation/web.Template.PETER-PC.Debug.config +++ b/src/umbraco.presentation/web.Template.PeterGregory-PC.Debug.config @@ -17,10 +17,14 @@ + value="server=localhost;database=4.8.dev;user id=sa;password=password!"/> - + value="4.8.1"/> + + + diff --git a/src/umbraco.presentation/web.config b/src/umbraco.presentation/web.config index 03adb3e518..91afe67f16 100644 --- a/src/umbraco.presentation/web.config +++ b/src/umbraco.presentation/web.config @@ -3,7 +3,7 @@
- +
@@ -26,12 +26,12 @@ - - + + - - + + From 13558b77dcc25d23b8f88222caf0c580de0d77aa Mon Sep 17 00:00:00 2001 From: pgregorynz Date: Mon, 13 Aug 2012 20:39:17 -1000 Subject: [PATCH 22/24] Type in code comment fixed. --- src/umbraco.presentation/umbraco/Trees/loadMedia.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/umbraco.presentation/umbraco/Trees/loadMedia.cs b/src/umbraco.presentation/umbraco/Trees/loadMedia.cs index 2a92e8dcc8..db734995ea 100644 --- a/src/umbraco.presentation/umbraco/Trees/loadMedia.cs +++ b/src/umbraco.presentation/umbraco/Trees/loadMedia.cs @@ -56,8 +56,8 @@ namespace umbraco /// - /// Returns the Document object of the starting node for the current User. This ensures - /// that the Document object is only instantiated once. + /// Returns the Media object of the starting node for the current User. This ensures + /// that the Media object is only instantiated once. /// protected Media StartNode { From b8f7ea50f718103c1692bb0fdde57697aa4c9458 Mon Sep 17 00:00:00 2001 From: sebastiaan Date: Tue, 14 Aug 2012 07:06:26 -0200 Subject: [PATCH 23/24] Added tag Release-4.8.1 for changeset 8f8a20385788 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 6003cea89b..485e19b183 100644 --- a/.hgtags +++ b/.hgtags @@ -7,3 +7,4 @@ ffc34b23e1a03785e4098afa4290d8c03cf10115 Release-4.5.2 d03fcffb8834a9583a56813bb44b6abbd9f042cc Release-4.6.0 1809f7b2593270c192cd47bdcfdb392100686f79 4.7.2 488779dec0ceb1d2874bcef906241b919325c904 4.8.0-beta +8f8a203857886b373148af29edd57460a42940be Release-4.8.1 From cff0d9dfbfa611dbaadc6a5f3c7aa8cafc95c04c Mon Sep 17 00:00:00 2001 From: sebastiaan Date: Tue, 14 Aug 2012 07:15:32 -0200 Subject: [PATCH 24/24] Closing branch.