diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index 091f07bd19..0419fb0cd0 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -75,6 +75,8 @@ namespace Umbraco.Core
//initialize the DatabaseContext
dbContext.Initialize();
+ InitializeModelMappers();
+
//now we need to call the initialize methods
ApplicationEventsResolver.Current.ApplicationEventHandlers
.ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext));
@@ -95,6 +97,14 @@ namespace Umbraco.Core
ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext);
}
+ ///
+ /// This method allows for configuration of model mappers
+ ///
+ protected virtual void InitializeModelMappers()
+ {
+ //TODO: There will most likely be AutoMapper configs to put in here, we know they exist in web for now so we'll leave this here for future use
+ }
+
///
/// Special method to initialize the ProfilerResolver
///
diff --git a/src/Umbraco.Tests/App.config b/src/Umbraco.Tests/App.config
index b4fa2f7a10..cfbefb6754 100644
--- a/src/Umbraco.Tests/App.config
+++ b/src/Umbraco.Tests/App.config
@@ -22,7 +22,6 @@
-
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbavatar.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbavatar.directive.js
index d83fc90ed3..c39f5ce0a5 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/umbavatar.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbavatar.directive.js
@@ -7,7 +7,16 @@ function avatarDirective() {
return {
restrict: "E", // restrict to an element
replace: true, // replace the html element with the template
- templateUrl: 'views/directives/umb-avatar.html'
+ templateUrl: 'views/directives/umb-avatar.html',
+ scope: {
+ name: '@',
+ email: '@',
+ hash: '@',
+ },
+ link: function(scope, element, attr, ctrl) {
+ //set the gravatar url
+ scope.gravatar = "http://www.gravatar.com/avatar/" + scope.hash + "?s=40";
+ }
};
}
diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/umb-avatar.html b/src/Umbraco.Web.UI.Client/src/views/directives/umb-avatar.html
index b69a0a711f..48a4a776ba 100644
--- a/src/Umbraco.Web.UI.Client/src/views/directives/umb-avatar.html
+++ b/src/Umbraco.Web.UI.Client/src/views/directives/umb-avatar.html
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/umb-leftcolumn.html b/src/Umbraco.Web.UI.Client/src/views/directives/umb-leftcolumn.html
index 4ac78128cd..72c1bd17b1 100644
--- a/src/Umbraco.Web.UI.Client/src/views/directives/umb-leftcolumn.html
+++ b/src/Umbraco.Web.UI.Client/src/views/directives/umb-leftcolumn.html
@@ -3,7 +3,7 @@
-
-
+
-
diff --git a/src/Umbraco.Web.UI/umbraco/Views/directives/umb-leftcolumn.html b/src/Umbraco.Web.UI/umbraco/Views/directives/umb-leftcolumn.html
index 4ac78128cd..72c1bd17b1 100644
--- a/src/Umbraco.Web.UI/umbraco/Views/directives/umb-leftcolumn.html
+++ b/src/Umbraco.Web.UI/umbraco/Views/directives/umb-leftcolumn.html
@@ -3,7 +3,7 @@
-
-
+
-
diff --git a/src/Umbraco.Web.UI/web.Template.Debug.config b/src/Umbraco.Web.UI/web.Template.Debug.config
index 937cee3f3a..de074b944e 100644
--- a/src/Umbraco.Web.UI/web.Template.Debug.config
+++ b/src/Umbraco.Web.UI/web.Template.Debug.config
@@ -28,8 +28,8 @@
+
-
diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config
index 5438ea097b..19dceac49d 100644
--- a/src/Umbraco.Web.UI/web.Template.config
+++ b/src/Umbraco.Web.UI/web.Template.config
@@ -45,7 +45,6 @@
-
@@ -283,4 +282,4 @@
-
+
diff --git a/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs b/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs
index 74fe5e641c..70aaa0cd77 100644
--- a/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs
+++ b/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs
@@ -13,5 +13,11 @@ namespace Umbraco.Web.Models.ContentEditing
[DataMember(Name = "locale", IsRequired = true)]
[Required]
public string Language { get; set; }
+
+ ///
+ /// The MD5 lowercase hash of the email which can be used by gravatar
+ ///
+ [DataMember(Name = "emailHash")]
+ public string EmailHash { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs b/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs
index f6eee6750c..ad5fde9b5b 100644
--- a/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs
+++ b/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs
@@ -1,4 +1,5 @@
using System;
+using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Models.Membership;
using Umbraco.Web.Models.ContentEditing;
@@ -7,36 +8,39 @@ namespace Umbraco.Web.Models.Mapping
{
internal class UserModelMapper
{
- public UserDetail ToUserDetail(IUser user)
+ ///
+ /// Configures the automapper mappings
+ ///
+ internal static void Configure()
{
- var detail = new UserDetail
- {
- Name = user.Name,
- Email = user.Email,
- Language = user.Language
- };
- var result = user.Id.TryConvertTo();
+ Mapper.CreateMap()
+ .ForMember(detail => detail.UserId, opt => opt.MapFrom(user => GetIntId(user.Id)))
+ .ForMember(
+ detail => detail.EmailHash,
+ opt => opt.MapFrom(user => user.Email.ToLowerInvariant().Trim().ToMd5()));
+ Mapper.CreateMap()
+ .ForMember(detail => detail.UserId, opt => opt.MapFrom(profile => GetIntId(profile.Id)));
+ }
+
+ private static int GetIntId(object id)
+ {
+ var result = id.TryConvertTo();
if (result.Success == false)
{
- throw new InvalidOperationException("Cannot convert the profile to a " + typeof(UserDetail).Name + " object since the id is not an integer");
+ throw new InvalidOperationException(
+ "Cannot convert the profile to a " + typeof(UserDetail).Name + " object since the id is not an integer");
}
- detail.UserId = result.Result;
- return detail;
+ return result.Result;
+ }
+
+ public UserDetail ToUserDetail(IUser user)
+ {
+ return Mapper.Map(user);
}
public UserBasic ToUserBasic(IProfile profile)
{
- var user = new UserBasic
- {
- Name = profile.Name
- };
- var result = profile.Id.TryConvertTo();
- if (result.Success == false)
- {
- throw new InvalidOperationException("Cannot convert the profile to a " + typeof(UserBasic).Name + " object since the id is not an integer");
- }
- user.UserId = result.Result;
- return user;
+ return Mapper.Map(profile);
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index cd7fae9060..14a549d9a5 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -95,6 +95,9 @@
{07fbc26b-2927-4a22-8d96-d644c667fecc}
UmbracoExamine
+
+ ..\packages\AutoMapper.2.2.1\lib\net40\AutoMapper.dll
+
False
..\packages\ClientDependency.1.7.0.2\lib\ClientDependency.Core.dll
@@ -309,7 +312,6 @@
-
diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs
index 1e51f126d9..a166b96702 100644
--- a/src/Umbraco.Web/WebBootManager.cs
+++ b/src/Umbraco.Web/WebBootManager.cs
@@ -20,6 +20,7 @@ using Umbraco.Web.Editors;
using Umbraco.Web.Media;
using Umbraco.Web.Media.ThumbnailProviders;
using Umbraco.Web.Models;
+using Umbraco.Web.Models.Mapping;
using Umbraco.Web.Mvc;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web.PublishedCache;
@@ -111,6 +112,15 @@ namespace Umbraco.Web
ProfilerResolver.Current.SetProfiler(new WebProfiler());
}
+ ///
+ /// Configure the model mappers
+ ///
+ protected override void InitializeModelMappers()
+ {
+ base.InitializeModelMappers();
+ UserModelMapper.Configure();
+ }
+
///
/// Adds custom types to the ApplicationEventsResolver
///
diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config
index d370ef28d5..9f5ddf7b61 100644
--- a/src/Umbraco.Web/packages.config
+++ b/src/Umbraco.Web/packages.config
@@ -1,5 +1,6 @@
+
diff --git a/src/umbraco.businesslogic/GlobalSettings.cs b/src/umbraco.businesslogic/GlobalSettings.cs
index dd77f843b1..1ba730ecfb 100644
--- a/src/umbraco.businesslogic/GlobalSettings.cs
+++ b/src/umbraco.businesslogic/GlobalSettings.cs
@@ -101,31 +101,6 @@ namespace umbraco
get { return Umbraco.Core.SystemUtilities.GetCurrentTrustLevel(); }
}
-
- ///
- /// Forces umbraco to be medium trust compatible
- ///
- /// If true, umbraco will be medium-trust compatible, no matter what Permission level the server is on.
- [Obsolete("This property is no longer used and will be removed in future versions")]
- public static bool UseMediumTrust
- {
- get
- {
- try
- {
- var trustLevel = SystemUtilities.GetCurrentTrustLevel();
- if (trustLevel == AspNetHostingPermissionLevel.High || trustLevel == AspNetHostingPermissionLevel.Unrestricted)
- return false;
- else
- return bool.Parse(ConfigurationManager.AppSettings["umbracoUseMediumTrust"]);
- }
- catch
- {
- return false;
- }
- }
- }
-
///
/// Saves a setting into the configuration file.
///