- When a published page gets renamed a redirect will automatically be made to the new page
+
No redirects have been made
+ When a published page gets renamed or moved a redirect will automatically be made to the new page
- developer
+ content
diff --git a/src/Umbraco.Web.UI/config/Dashboard.config b/src/Umbraco.Web.UI/config/Dashboard.config
index 9eb808c67c..81bd9be6e8 100644
--- a/src/Umbraco.Web.UI/config/Dashboard.config
+++ b/src/Umbraco.Web.UI/config/Dashboard.config
@@ -111,7 +111,7 @@
- developer
+ content
diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml
index 89f3152438..838bbbe8d6 100644
--- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml
+++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml
@@ -1416,4 +1416,21 @@ To manage your website, simply open the Umbraco back office and start adding con
%0%.]]>%0%.]]>
+
+ Disable URL tracker
+ Enable URL tracker
+ Original URL
+ Redirected To
+ No redirects have been made
+ When a published page gets renamed or moved a redirect will automatically be made to the new page.
+ Remove
+ Are you sure you want to remove the redirect from '%0%' to '%1%'?
+ Redirect URL removed.
+ Error removing redirect URL.
+ Are you sure you want to disable the URL tracker?
+ URL tracker has now been disabled.
+ Error disabling the URL tracker, more information can be found in your log file.
+ URL tracker has now been enabled.
+ Error enabling the URL tracker, more information can be found in your log file.
+
diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
index dd9931ed06..aeeb441281 100644
--- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
+++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml
@@ -1420,4 +1420,21 @@ To manage your website, simply open the Umbraco back office and start adding con
%0%.]]>%0%.]]>
+
+ Disable URL tracker
+ Enable URL tracker
+ Original URL
+ Redirected To
+ No redirects have been made
+ When a published page gets renamed or moved a redirect will automatically be made to the new page.
+ Remove
+ Are you sure you want to remove the redirect from '%0%' to '%1%'?
+ Redirect URL removed.
+ Error removing redirect URL.
+ Are you sure you want to disable the URL tracker?
+ URL tracker has now been disabled.
+ Error disabling the URL tracker, more information can be found in your log file.
+ URL tracker has now been enabled.
+ Error enabling the URL tracker, more information can be found in your log file.
+
diff --git a/src/Umbraco.Web.UI/umbraco/users/PermissionEditor.aspx b/src/Umbraco.Web.UI/umbraco/users/PermissionEditor.aspx
index c67837b5e6..815a420f88 100644
--- a/src/Umbraco.Web.UI/umbraco/users/PermissionEditor.aspx
+++ b/src/Umbraco.Web.UI/umbraco/users/PermissionEditor.aspx
@@ -9,7 +9,6 @@
-
diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs
index b505387257..199ffd9bed 100644
--- a/src/Umbraco.Web/Editors/BackOfficeController.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeController.cs
@@ -226,7 +226,7 @@ namespace Umbraco.Web.Editors
//API URLs
{
"redirectUrlManagementApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
- controller => controller.IsEnabled())
+ controller => controller.GetEnableState())
},
{
"embedApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
diff --git a/src/Umbraco.Web/Editors/RedirectUrlManagementController.cs b/src/Umbraco.Web/Editors/RedirectUrlManagementController.cs
index 9c55e0df01..8ccfd6dde7 100644
--- a/src/Umbraco.Web/Editors/RedirectUrlManagementController.cs
+++ b/src/Umbraco.Web/Editors/RedirectUrlManagementController.cs
@@ -1,11 +1,13 @@
using System;
-using System.Web.Hosting;
using System.Web.Http;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
+using umbraco.businesslogic.Exceptions;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Models;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
@@ -22,9 +24,11 @@ namespace Umbraco.Web.Editors
///
///
[HttpGet]
- public bool IsEnabled()
+ public IHttpActionResult GetEnableState()
{
- return UmbracoConfig.For.UmbracoSettings().WebRouting.DisableRedirectUrlTracking == false;
+ var enabled = UmbracoConfig.For.UmbracoSettings().WebRouting.DisableRedirectUrlTracking == false;
+ var userIsAdmin = Umbraco.UmbracoContext.Security.CurrentUser.IsAdmin();
+ return Ok(new { enabled, userIsAdmin });
}
//add paging
@@ -65,6 +69,15 @@ namespace Umbraco.Web.Editors
[HttpPost]
public IHttpActionResult ToggleUrlTracker(bool disable)
{
+ var userIsAdmin = Umbraco.UmbracoContext.Security.CurrentUser.IsAdmin();
+ if (userIsAdmin == false)
+ {
+ var errorMessage = string.Format("User of type {0} is not allowed to toggle the URL tracker",
+ Umbraco.UmbracoContext.Security.CurrentUser.UserType.Alias);
+ LogHelper.Debug(errorMessage);
+ throw new UserAuthorizationException(errorMessage);
+ }
+
var httpContext = TryGetHttpContext();
if (httpContext.Success == false) throw new InvalidOperationException("Cannot acquire HttpContext");
var configFilePath = httpContext.Result.Server.MapPath("~/config/umbracoSettings.config");
diff --git a/src/Umbraco.Web/Editors/UpdateCheckController.cs b/src/Umbraco.Web/Editors/UpdateCheckController.cs
index 8f159d308d..e42ef0ffb9 100644
--- a/src/Umbraco.Web/Editors/UpdateCheckController.cs
+++ b/src/Umbraco.Web/Editors/UpdateCheckController.cs
@@ -1,12 +1,10 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
-using System.Text;
-using System.Threading.Tasks;
using System.Web.Http.Filters;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Models;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
@@ -20,7 +18,7 @@ namespace Umbraco.Web.Editors
{
var updChkCookie = Request.Headers.GetCookies("UMB_UPDCHK").FirstOrDefault();
var updateCheckCookie = updChkCookie != null ? updChkCookie["UMB_UPDCHK"].Value : "";
- if (GlobalSettings.VersionCheckPeriod > 0 && string.IsNullOrEmpty(updateCheckCookie) && Security.CurrentUser.UserType.Alias == "admin")
+ if (GlobalSettings.VersionCheckPeriod > 0 && string.IsNullOrEmpty(updateCheckCookie) && Security.CurrentUser.IsAdmin())
{
try
{
diff --git a/src/Umbraco.Web/Install/Controllers/InstallController.cs b/src/Umbraco.Web/Install/Controllers/InstallController.cs
index 572bd0a192..360e35efda 100644
--- a/src/Umbraco.Web/Install/Controllers/InstallController.cs
+++ b/src/Umbraco.Web/Install/Controllers/InstallController.cs
@@ -44,6 +44,10 @@ namespace Umbraco.Web.Install.Controllers
if (ApplicationContext.Current.IsUpgrading)
{
+ // Update ClientDependency version
+ var clientDependencyConfig = new ClientDependencyConfiguration(ApplicationContext.Current.ProfilingLogger.Logger);
+ var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();
+
var result = _umbracoContext.Security.ValidateCurrentUser(false);
switch (result)
diff --git a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
index 78fe6d3766..0de405ebef 100644
--- a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
+++ b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
@@ -49,10 +49,6 @@ namespace Umbraco.Web.Install.InstallSteps
// Update configurationStatus
GlobalSettings.ConfigurationStatus = UmbracoVersion.GetSemanticVersion().ToSemanticString();
-
- // Update ClientDependency version
- var clientDependencyConfig = new ClientDependencyConfiguration(_applicationContext.ProfilingLogger.Logger);
- var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();
//reports the ended install
ih.InstallStatus(true, "");
diff --git a/src/Umbraco.Web/Models/Mapping/DashboardModelsMapper.cs b/src/Umbraco.Web/Models/Mapping/DashboardModelsMapper.cs
index a87ea4eeb9..66510a2263 100644
--- a/src/Umbraco.Web/Models/Mapping/DashboardModelsMapper.cs
+++ b/src/Umbraco.Web/Models/Mapping/DashboardModelsMapper.cs
@@ -1,9 +1,12 @@
-using AutoMapper;
+using System;
+using System.Linq;
+using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Models.Mapping;
using Umbraco.Web.Models.ContentEditing;
using umbraco.BusinessLogic;
using Umbraco.Core.Models;
+using Umbraco.Web.Routing;
namespace Umbraco.Web.Models.Mapping
{
@@ -15,7 +18,7 @@ namespace Umbraco.Web.Models.Mapping
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
{
config.CreateMap()
- .ForMember(x => x.OriginalUrl, expression => expression.MapFrom(item => item.Url))
+ .ForMember(x => x.OriginalUrl, expression => expression.MapFrom(item => UmbracoContext.Current.UrlProvider.GetUrlFromRoute(item.ContentId, item.Url)))
.ForMember(x => x.DestinationUrl, expression => expression.Ignore())
.ForMember(x => x.RedirectId, expression => expression.MapFrom(item => item.Key));
diff --git a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs
index 915636889d..d55095d151 100644
--- a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs
+++ b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs
@@ -52,7 +52,11 @@ namespace Umbraco.Web.Routing
// will not use cache if previewing
var route = umbracoContext.ContentCache.GetRouteById(id);
+ return GetUrlFromRoute(route, umbracoContext, id, current, mode);
+ }
+ internal string GetUrlFromRoute(string route, UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
+ {
if (string.IsNullOrWhiteSpace(route))
{
LogHelper.Debug(
@@ -75,7 +79,7 @@ namespace Umbraco.Web.Routing
// route is / or /
var pos = route.IndexOf('/');
var path = pos == 0 ? route : route.Substring(pos);
- var domainUri = pos == 0
+ var domainUri = pos == 0
? null
: domainHelper.DomainForNode(int.Parse(route.Substring(0, pos)), current);
diff --git a/src/Umbraco.Web/Routing/PublishedContentRequest.cs b/src/Umbraco.Web/Routing/PublishedContentRequest.cs
index 2081fd69b5..9c21958603 100644
--- a/src/Umbraco.Web/Routing/PublishedContentRequest.cs
+++ b/src/Umbraco.Web/Routing/PublishedContentRequest.cs
@@ -589,13 +589,10 @@ namespace Umbraco.Web.Routing
///
/// Gets or sets the System.Web.HttpCacheability
///
- /// Is set to System.Web.HttpCacheability.Private by default, which is the ASP.NET default.
- private HttpCacheability _cacheability = HttpCacheability.Private;
- internal HttpCacheability Cacheability
- {
- get { return _cacheability; }
- set { _cacheability = value; }
- }
+ // Note: we used to set a default value here but that would then be the default
+ // for ALL requests, we shouldn't overwrite it though if people are using [OutputCache] for example
+ // see: https://our.umbraco.org/forum/using-umbraco-and-getting-started/79715-output-cache-in-umbraco-752
+ internal HttpCacheability Cacheability { get; set; }
///
/// Gets or sets a list of Extensions to append to the Response.Cache object
diff --git a/src/Umbraco.Web/Routing/UrlProvider.cs b/src/Umbraco.Web/Routing/UrlProvider.cs
index 714ba64e64..2bb012d207 100644
--- a/src/Umbraco.Web/Routing/UrlProvider.cs
+++ b/src/Umbraco.Web/Routing/UrlProvider.cs
@@ -147,6 +147,15 @@ namespace Umbraco.Web.Routing
return url ?? "#"; // legacy wants this
}
+ internal string GetUrlFromRoute(int id, string route)
+ {
+ var provider = _urlProviders.OfType().FirstOrDefault();
+ var url = provider == null
+ ? route // what else?
+ : provider.GetUrlFromRoute(route, UmbracoContext.Current, id, _umbracoContext.CleanedUmbracoUrl, Mode);
+ return url ?? "#";
+ }
+
#endregion
#region GetOtherUrls
diff --git a/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs b/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs
index 7074a6db9f..76c06fbac2 100644
--- a/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs
+++ b/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs
@@ -8,7 +8,16 @@ namespace Umbraco.Web.Security.Identity
{
public static class AuthenticationOptionsExtensions
{
-
+
+ ///
+ /// When trying to implement an Azure AD B2C provider or other OAuth provider that requires a customized Challenge Result in order to work then
+ /// this must be used.
+ ///
+ ///
+ ///
+ ///
+ /// See: http://issues.umbraco.org/issue/U4-7353
+ ///
public static void SetSignInChallengeResultCallback(
this AuthenticationOptions authOptions,
Func authProperties)
diff --git a/src/Umbraco.Web/UI/Bundles/JsJQueryCore.cs b/src/Umbraco.Web/UI/Bundles/JsJQueryCore.cs
index 621ecd214c..9bd6509ae7 100644
--- a/src/Umbraco.Web/UI/Bundles/JsJQueryCore.cs
+++ b/src/Umbraco.Web/UI/Bundles/JsJQueryCore.cs
@@ -8,6 +8,7 @@ namespace Umbraco.Web.UI.Bundles
///
[ClientDependency(ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient", Priority = 0, Group = 1)]
[ClientDependency(ClientDependencyType.Javascript, "ui/jqueryui.js", "UmbracoClient", Priority = 1, Group = 1)]
+ [ClientDependency(ClientDependencyType.Javascript, "lib/jquery-migrate/jquery-migrate.min.js", "UmbracoRoot", Priority = 2, Group = 1)]
public class JsJQueryCore : Control
{
}
diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs
index d613596f56..a80188f449 100644
--- a/src/Umbraco.Web/UmbracoModule.cs
+++ b/src/Umbraco.Web/UmbracoModule.cs
@@ -324,7 +324,8 @@ namespace Umbraco.Web
() => pcr.IsRedirect ? (pcr.IsRedirectPermanent ? "permanent" : "redirect") : "none",
() => pcr.Is404 ? "true" : "false", () => pcr.ResponseStatusCode);
- response.Cache.SetCacheability(pcr.Cacheability);
+ if(pcr.Cacheability != default(HttpCacheability))
+ response.Cache.SetCacheability(pcr.Cacheability);
foreach (var cacheExtension in pcr.CacheExtensions)
response.Cache.AppendCacheExtension(cacheExtension);
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx
index c67837b5e6..815a420f88 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx
@@ -9,7 +9,6 @@
-
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx.designer.cs
index 639adc5569..e0c1494dd4 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx.designer.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/users/PermissionEditor.aspx.designer.cs
@@ -39,15 +39,6 @@ namespace umbraco.cms.presentation.user {
///
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
- ///
- /// JsInclude2 control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::ClientDependency.Core.Controls.JsInclude JsInclude2;
-
///
/// pnlUmbraco control.
///
diff --git a/src/umbraco.businesslogic/User.cs b/src/umbraco.businesslogic/User.cs
index b7beb7db5d..59b6c19a41 100644
--- a/src/umbraco.businesslogic/User.cs
+++ b/src/umbraco.businesslogic/User.cs
@@ -184,9 +184,10 @@ namespace umbraco.BusinessLogic
///
/// true if this user is admin; otherwise, false.
///
+ [Obsolete("Use Umbraco.Core.Models.IsAdmin extension method instead", false)]
public bool IsAdmin()
{
- return UserType.Alias == "admin";
+ return UserEntity.IsAdmin();
}
[Obsolete("Do not use this method to validate credentials, use the user's membership provider to do authentication. This method will not work if the password format is 'Encrypted'")]
diff --git a/src/umbraco.cms/businesslogic/Packager/Installer.cs b/src/umbraco.cms/businesslogic/Packager/Installer.cs
index 6b4f9edde2..bc1c062631 100644
--- a/src/umbraco.cms/businesslogic/Packager/Installer.cs
+++ b/src/umbraco.cms/businesslogic/Packager/Installer.cs
@@ -12,10 +12,8 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Packaging;
using umbraco.cms.businesslogic.web;
-using umbraco.cms.businesslogic.propertytype;
using umbraco.BusinessLogic;
using System.Diagnostics;
-using System.Security;
using umbraco.cms.businesslogic.macro;
using umbraco.cms.businesslogic.template;
using umbraco.interfaces;
@@ -188,8 +186,16 @@ namespace umbraco.cms.businesslogic.packager
// Check if the file is a valid package
if (fi.Extension.ToLower() == ".umb")
{
- tempDir = UnPack(fi.FullName, deleteFile);
- LoadConfig(tempDir);
+ try
+ {
+ tempDir = UnPack(fi.FullName, deleteFile);
+ LoadConfig(tempDir);
+ }
+ catch (Exception exception)
+ {
+ LogHelper.Error(string.Format("Error importing file {0}", fi.FullName), exception);
+ throw;
+ }
}
else
throw new Exception("Error - file isn't a package (doesn't have a .umb extension). Check if the file automatically got named '.zip' upon download.");
@@ -272,24 +278,57 @@ namespace umbraco.cms.businesslogic.packager
//string virtualBasePath = System.Web.HttpContext.Current.Request.ApplicationPath;
string basePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
- foreach (XmlNode n in Config.DocumentElement.SelectNodes("//file"))
+ try
{
- var destPath = GetFileName(basePath, XmlHelper.GetNodeValue(n.SelectSingleNode("orgPath")));
- var sourceFile = GetFileName(tempDir, XmlHelper.GetNodeValue(n.SelectSingleNode("guid")));
- var destFile = GetFileName(destPath, XmlHelper.GetNodeValue(n.SelectSingleNode("orgName")));
+ foreach (XmlNode n in Config.DocumentElement.SelectNodes("//file"))
+ {
+ var destPath = GetFileName(basePath, XmlHelper.GetNodeValue(n.SelectSingleNode("orgPath")));
+ var sourceFile = GetFileName(tempDir, XmlHelper.GetNodeValue(n.SelectSingleNode("guid")));
+ var destFile = GetFileName(destPath, XmlHelper.GetNodeValue(n.SelectSingleNode("orgName")));
- // Create the destination directory if it doesn't exist
- if (Directory.Exists(destPath) == false)
- Directory.CreateDirectory(destPath);
- //If a file with this name exists, delete it
- else if (File.Exists(destFile))
- File.Delete(destFile);
+ // Create the destination directory if it doesn't exist
+ if (Directory.Exists(destPath) == false)
+ Directory.CreateDirectory(destPath);
+ //If a file with this name exists, delete it
+ else if (File.Exists(destFile))
+ File.Delete(destFile);
- // Move the file
- File.Move(sourceFile, destFile);
+ // Copy the file
+ // SJ: Note - this used to do a move but some packages included the same file to be
+ // copied to multiple locations like so:
+ //
+ //
+ // my-icon.png
+ // /umbraco/Images/
+ // my-icon.png
+ //
+ //
+ // my-icon.png
+ // /App_Plugins/MyPlugin/Images
+ // my-icon.png
+ //
+ //
+ // Since this file unzips as a flat list of files, moving the file the first time means
+ // that when you try to do that a second time, it would result in a FileNotFoundException
+ File.Copy(sourceFile, destFile);
- //PPH log file install
- insPack.Data.Files.Add(XmlHelper.GetNodeValue(n.SelectSingleNode("orgPath")) + "/" + XmlHelper.GetNodeValue(n.SelectSingleNode("orgName")));
+ //PPH log file install
+ insPack.Data.Files.Add(XmlHelper.GetNodeValue(n.SelectSingleNode("orgPath")) + "/" + XmlHelper.GetNodeValue(n.SelectSingleNode("orgName")));
+
+ }
+
+ // Once we're done copying, remove all the files
+ foreach (XmlNode n in Config.DocumentElement.SelectNodes("//file"))
+ {
+ var sourceFile = GetFileName(tempDir, XmlHelper.GetNodeValue(n.SelectSingleNode("guid")));
+ if (File.Exists(sourceFile))
+ File.Delete(sourceFile);
+ }
+ }
+ catch (Exception exception)
+ {
+ LogHelper.Error("Package install error", exception);
+ throw;
}
// log that a user has install files
@@ -301,8 +340,6 @@ namespace umbraco.cms.businesslogic.packager
}
insPack.Save();
-
-
}
}
@@ -312,160 +349,169 @@ namespace umbraco.cms.businesslogic.packager
() => "Installing business logic for package id " + packageId + " into temp folder " + tempDir,
() => "Package business logic installation complete for package id " + packageId))
{
- //retrieve the manifest to continue installation
- var insPack = InstalledPackage.GetById(packageId);
- //bool saveNeeded = false;
-
- // Get current user, with a fallback
- var currentUser = new User(0);
-
- //if there's a context, try to resolve the user - this will return null if there is a context but no
- // user found when there are old/invalid cookies lying around most likely during installation.
- // in that case we'll keep using the admin user
- if (string.IsNullOrEmpty(BasePages.UmbracoEnsuredPage.umbracoUserContextID) == false)
+ InstalledPackage insPack;
+ try
{
- if (BasePages.UmbracoEnsuredPage.ValidateUserContextID(BasePages.UmbracoEnsuredPage.umbracoUserContextID))
+ //retrieve the manifest to continue installation
+ insPack = InstalledPackage.GetById(packageId);
+ //bool saveNeeded = false;
+
+ // Get current user, with a fallback
+ var currentUser = new User(0);
+
+ //if there's a context, try to resolve the user - this will return null if there is a context but no
+ // user found when there are old/invalid cookies lying around most likely during installation.
+ // in that case we'll keep using the admin user
+ if (string.IsNullOrEmpty(BasePages.UmbracoEnsuredPage.umbracoUserContextID) == false)
{
- var userById = User.GetCurrent();
- if (userById != null)
- currentUser = userById;
- }
- }
-
-
- //Xml as XElement which is used with the new PackagingService
- var rootElement = Config.DocumentElement.GetXElement();
- var packagingService = ApplicationContext.Current.Services.PackagingService;
-
- //Perhaps it would have been a good idea to put the following into methods eh?!?
-
- #region DataTypes
- var dataTypeElement = rootElement.Descendants("DataTypes").FirstOrDefault();
- if (dataTypeElement != null)
- {
- var dataTypeDefinitions = packagingService.ImportDataTypeDefinitions(dataTypeElement, currentUser.Id);
- foreach (var dataTypeDefinition in dataTypeDefinitions)
- {
- insPack.Data.DataTypes.Add(dataTypeDefinition.Id.ToString(CultureInfo.InvariantCulture));
- }
- }
- #endregion
-
- #region Languages
- var languageItemsElement = rootElement.Descendants("Languages").FirstOrDefault();
- if (languageItemsElement != null)
- {
- var insertedLanguages = packagingService.ImportLanguages(languageItemsElement);
- insPack.Data.Languages.AddRange(insertedLanguages.Select(l => l.Id.ToString()));
- }
-
- #endregion
-
- #region Dictionary items
- var dictionaryItemsElement = rootElement.Descendants("DictionaryItems").FirstOrDefault();
- if (dictionaryItemsElement != null)
- {
- var insertedDictionaryItems = packagingService.ImportDictionaryItems(dictionaryItemsElement);
- insPack.Data.DictionaryItems.AddRange(insertedDictionaryItems.Select(d => d.Id.ToString()));
- }
- #endregion
-
- #region Macros
- foreach (XmlNode n in Config.DocumentElement.SelectNodes("//macro"))
- {
- //TODO: Fix this, this should not use the legacy API
- Macro m = Macro.Import(n);
-
- if (m != null)
- {
- insPack.Data.Macros.Add(m.Id.ToString(CultureInfo.InvariantCulture));
- //saveNeeded = true;
- }
- }
-
- //if (saveNeeded) { insPack.Save(); saveNeeded = false; }
- #endregion
-
- #region Templates
- var templateElement = rootElement.Descendants("Templates").FirstOrDefault();
- if (templateElement != null)
- {
- var templates = packagingService.ImportTemplates(templateElement, currentUser.Id);
- foreach (var template in templates)
- {
- insPack.Data.Templates.Add(template.Id.ToString(CultureInfo.InvariantCulture));
- }
- }
- #endregion
-
- #region DocumentTypes
- //Check whether the root element is a doc type rather then a complete package
- var docTypeElement = rootElement.Name.LocalName.Equals("DocumentType") ||
- rootElement.Name.LocalName.Equals("DocumentTypes")
- ? rootElement
- : rootElement.Descendants("DocumentTypes").FirstOrDefault();
-
- if (docTypeElement != null)
- {
- var contentTypes = packagingService.ImportContentTypes(docTypeElement, currentUser.Id);
- foreach (var contentType in contentTypes)
- {
- insPack.Data.Documenttypes.Add(contentType.Id.ToString(CultureInfo.InvariantCulture));
- //saveNeeded = true;
- }
- }
- #endregion
-
- #region Stylesheets
- foreach (XmlNode n in Config.DocumentElement.SelectNodes("Stylesheets/Stylesheet"))
- {
- StyleSheet s = StyleSheet.Import(n, currentUser);
-
- insPack.Data.Stylesheets.Add(s.Id.ToString());
- //saveNeeded = true;
- }
-
- //if (saveNeeded) { insPack.Save(); saveNeeded = false; }
- #endregion
-
- #region Documents
- var documentElement = rootElement.Descendants("DocumentSet").FirstOrDefault();
- if (documentElement != null)
- {
- var content = packagingService.ImportContent(documentElement, -1, currentUser.Id);
- var firstContentItem = content.First();
- insPack.Data.ContentNodeId = firstContentItem.Id.ToString(CultureInfo.InvariantCulture);
- }
- #endregion
-
- #region Package Actions
- foreach (XmlNode n in Config.DocumentElement.SelectNodes("Actions/Action"))
- {
- if (n.Attributes["undo"] == null || n.Attributes["undo"].Value == "true")
- {
- insPack.Data.Actions += n.OuterXml;
- }
-
- //Run the actions tagged only for 'install'
-
- if (n.Attributes["runat"] != null && n.Attributes["runat"].Value == "install")
- {
- var alias = n.Attributes["alias"] != null ? n.Attributes["alias"].Value : "";
-
- if (alias.IsNullOrWhiteSpace() == false)
+ if (BasePages.UmbracoEnsuredPage.ValidateUserContextID(BasePages.UmbracoEnsuredPage.umbracoUserContextID))
{
- PackageAction.RunPackageAction(insPack.Data.Name, alias, n);
+ var userById = User.GetCurrent();
+ if (userById != null)
+ currentUser = userById;
}
}
+
+
+ //Xml as XElement which is used with the new PackagingService
+ var rootElement = Config.DocumentElement.GetXElement();
+ var packagingService = ApplicationContext.Current.Services.PackagingService;
+
+ //Perhaps it would have been a good idea to put the following into methods eh?!?
+
+ #region DataTypes
+ var dataTypeElement = rootElement.Descendants("DataTypes").FirstOrDefault();
+ if (dataTypeElement != null)
+ {
+ var dataTypeDefinitions = packagingService.ImportDataTypeDefinitions(dataTypeElement, currentUser.Id);
+ foreach (var dataTypeDefinition in dataTypeDefinitions)
+ {
+ insPack.Data.DataTypes.Add(dataTypeDefinition.Id.ToString(CultureInfo.InvariantCulture));
+ }
+ }
+ #endregion
+
+ #region Languages
+ var languageItemsElement = rootElement.Descendants("Languages").FirstOrDefault();
+ if (languageItemsElement != null)
+ {
+ var insertedLanguages = packagingService.ImportLanguages(languageItemsElement);
+ insPack.Data.Languages.AddRange(insertedLanguages.Select(l => l.Id.ToString()));
+ }
+
+ #endregion
+
+ #region Dictionary items
+ var dictionaryItemsElement = rootElement.Descendants("DictionaryItems").FirstOrDefault();
+ if (dictionaryItemsElement != null)
+ {
+ var insertedDictionaryItems = packagingService.ImportDictionaryItems(dictionaryItemsElement);
+ insPack.Data.DictionaryItems.AddRange(insertedDictionaryItems.Select(d => d.Id.ToString()));
+ }
+ #endregion
+
+ #region Macros
+ foreach (XmlNode n in Config.DocumentElement.SelectNodes("//macro"))
+ {
+ //TODO: Fix this, this should not use the legacy API
+ Macro m = Macro.Import(n);
+
+ if (m != null)
+ {
+ insPack.Data.Macros.Add(m.Id.ToString(CultureInfo.InvariantCulture));
+ //saveNeeded = true;
+ }
+ }
+
+ //if (saveNeeded) { insPack.Save(); saveNeeded = false; }
+ #endregion
+
+ #region Templates
+ var templateElement = rootElement.Descendants("Templates").FirstOrDefault();
+ if (templateElement != null)
+ {
+ var templates = packagingService.ImportTemplates(templateElement, currentUser.Id);
+ foreach (var template in templates)
+ {
+ insPack.Data.Templates.Add(template.Id.ToString(CultureInfo.InvariantCulture));
+ }
+ }
+ #endregion
+
+ #region DocumentTypes
+ //Check whether the root element is a doc type rather then a complete package
+ var docTypeElement = rootElement.Name.LocalName.Equals("DocumentType") ||
+ rootElement.Name.LocalName.Equals("DocumentTypes")
+ ? rootElement
+ : rootElement.Descendants("DocumentTypes").FirstOrDefault();
+
+ if (docTypeElement != null)
+ {
+ var contentTypes = packagingService.ImportContentTypes(docTypeElement, currentUser.Id);
+ foreach (var contentType in contentTypes)
+ {
+ insPack.Data.Documenttypes.Add(contentType.Id.ToString(CultureInfo.InvariantCulture));
+ //saveNeeded = true;
+ }
+ }
+ #endregion
+
+ #region Stylesheets
+ foreach (XmlNode n in Config.DocumentElement.SelectNodes("Stylesheets/Stylesheet"))
+ {
+ StyleSheet s = StyleSheet.Import(n, currentUser);
+
+ insPack.Data.Stylesheets.Add(s.Id.ToString());
+ //saveNeeded = true;
+ }
+
+ //if (saveNeeded) { insPack.Save(); saveNeeded = false; }
+ #endregion
+
+ #region Documents
+ var documentElement = rootElement.Descendants("DocumentSet").FirstOrDefault();
+ if (documentElement != null)
+ {
+ var content = packagingService.ImportContent(documentElement, -1, currentUser.Id);
+ var firstContentItem = content.First();
+ insPack.Data.ContentNodeId = firstContentItem.Id.ToString(CultureInfo.InvariantCulture);
+ }
+ #endregion
+
+ #region Package Actions
+ foreach (XmlNode n in Config.DocumentElement.SelectNodes("Actions/Action"))
+ {
+ if (n.Attributes["undo"] == null || n.Attributes["undo"].Value == "true")
+ {
+ insPack.Data.Actions += n.OuterXml;
+ }
+
+ //Run the actions tagged only for 'install'
+
+ if (n.Attributes["runat"] != null && n.Attributes["runat"].Value == "install")
+ {
+ var alias = n.Attributes["alias"] != null ? n.Attributes["alias"].Value : "";
+
+ if (alias.IsNullOrWhiteSpace() == false)
+ {
+ PackageAction.RunPackageAction(insPack.Data.Name, alias, n);
+ }
+ }
+ }
+ #endregion
+
+ // Trigger update of Apps / Trees config.
+ // (These are ApplicationStartupHandlers so just instantiating them will trigger them)
+ new ApplicationRegistrar();
+ new ApplicationTreeRegistrar();
+
+ insPack.Save();
+ }
+ catch (Exception exception)
+ {
+ LogHelper.Error("Error installing businesslogic", exception);
+ throw;
}
- #endregion
-
- // Trigger update of Apps / Trees config.
- // (These are ApplicationStartupHandlers so just instantiating them will trigger them)
- new ApplicationRegistrar();
- new ApplicationTreeRegistrar();
-
- insPack.Save();
OnPackageBusinessLogicInstalled(insPack);
}
@@ -504,15 +550,15 @@ namespace umbraco.cms.businesslogic.packager
RequirementsPatch = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/patch").FirstChild.Value);
var reqNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements");
- RequirementsType = reqNode != null && reqNode.Attributes != null && reqNode.Attributes["type"] != null
- ? Enum.Parse(reqNode.Attributes["type"].Value, true)
+ RequirementsType = reqNode != null && reqNode.Attributes != null && reqNode.Attributes["type"] != null
+ ? Enum.Parse(reqNode.Attributes["type"].Value, true)
: RequirementsType.Legacy;
var iconNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/iconUrl");
if (iconNode != null && iconNode.FirstChild != null)
{
IconUrl = iconNode.FirstChild.Value;
}
-
+
Author = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/name").FirstChild.Value;
AuthorUrl = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/website").FirstChild.Value;
@@ -630,7 +676,7 @@ namespace umbraco.cms.businesslogic.packager
Control = XmlHelper.GetNodeValue(controlNode);
}
}
-
+
///
/// This uses the old method of fetching and only supports the packages.umbraco.org repository.
///
@@ -760,7 +806,7 @@ namespace umbraco.cms.businesslogic.packager
{
File.Delete(zipName);
}
-
+
return tempDir;