From 15aa6fc4b821861bdb364b85e016c499473d408a Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 1 Apr 2014 11:53:43 +0200 Subject: [PATCH 01/11] Fixed U4-4576 7.0.4 : InternalMemberSearcher config incorrectly uses 'enableLeadingWildcards', should be 'enableLeadingWildcard' --- .../config/ExamineSettings.Release.config | 2 +- src/Umbraco.Web.UI/config/ExamineSettings.config | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI/config/ExamineSettings.Release.config b/src/Umbraco.Web.UI/config/ExamineSettings.Release.config index d19fce7c95..19b63dee7f 100644 --- a/src/Umbraco.Web.UI/config/ExamineSettings.Release.config +++ b/src/Umbraco.Web.UI/config/ExamineSettings.Release.config @@ -33,7 +33,7 @@ More information and documentation can be found on CodePlex: http://umbracoexami + analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/> diff --git a/src/Umbraco.Web.UI/config/ExamineSettings.config b/src/Umbraco.Web.UI/config/ExamineSettings.config index d19fce7c95..131867ac31 100644 --- a/src/Umbraco.Web.UI/config/ExamineSettings.config +++ b/src/Umbraco.Web.UI/config/ExamineSettings.config @@ -19,9 +19,9 @@ More information and documentation can be found on CodePlex: http://umbracoexami supportProtected="true" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/> - - - + + + @@ -29,11 +29,11 @@ More information and documentation can be found on CodePlex: http://umbracoexami - + - + + analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/> From 51660d918c184139c04586d3eeccd42ae730a75e Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 1 Apr 2014 14:22:13 +0200 Subject: [PATCH 02/11] Assembly redirect seems to help a lot installing NuGet pkg, should finally be able to close U4-4510 nuget targets file creates an invalid path in the property group --- src/Umbraco.Web.UI/web.Template.config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index ce9a488dc9..c4d625abb0 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -275,6 +275,11 @@ + + + + + From 40ebc1295c47549770ccb9e3c6139e24fdff5cb1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 1 Apr 2014 15:30:42 +0200 Subject: [PATCH 03/11] Fixes error thrown when saving password and actually using the Umbraco membership provider --- src/Umbraco.Core/Services/MemberService.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/Services/MemberService.cs b/src/Umbraco.Core/Services/MemberService.cs index 33b7721556..128ccea5f7 100644 --- a/src/Umbraco.Core/Services/MemberService.cs +++ b/src/Umbraco.Core/Services/MemberService.cs @@ -107,18 +107,21 @@ namespace Umbraco.Core.Services { provider.ChangePassword(member.Username, "", password); } + else + { + throw new NotSupportedException("When using a non-Umbraco membership provider you must change the member password by using the MembershipProvider.ChangePassword method"); + } //go re-fetch the member and update the properties that may have changed var result = GetByUsername(member.Username); - if (result != null) - { - //should never be null but it could have been deleted by another thread. - member.RawPasswordValue = result.RawPasswordValue; - member.LastPasswordChangeDate = result.LastPasswordChangeDate; - member.UpdateDate = member.UpdateDate; - } - - throw new NotSupportedException("When using a non-Umbraco membership provider you must change the member password by using the MembershipProvider.ChangePassword method"); + + //should never be null but it could have been deleted by another thread. + if (result == null) + return; + + member.RawPasswordValue = result.RawPasswordValue; + member.LastPasswordChangeDate = result.LastPasswordChangeDate; + member.UpdateDate = member.UpdateDate; } /// From 5b693f93105d3a893b8eefd87fb7e0d391e37029 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 1 Apr 2014 16:43:11 +0200 Subject: [PATCH 04/11] Adds ability to add/remove a single role to/from a single member, which is much nicer than having to instantiate arrays --- .../Services/IMembershipRoleService.cs | 4 ++++ src/Umbraco.Core/Services/MemberService.cs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Umbraco.Core/Services/IMembershipRoleService.cs b/src/Umbraco.Core/Services/IMembershipRoleService.cs index 46860e8c74..d66e9f17ac 100644 --- a/src/Umbraco.Core/Services/IMembershipRoleService.cs +++ b/src/Umbraco.Core/Services/IMembershipRoleService.cs @@ -14,9 +14,13 @@ namespace Umbraco.Core.Services IEnumerable GetMembersInRole(string roleName); IEnumerable FindMembersInRole(string roleName, string usernameToMatch, StringPropertyMatchType matchType = StringPropertyMatchType.StartsWith); bool DeleteRole(string roleName, bool throwIfBeingUsed); + void AssignRole(string username, string roleName); void AssignRoles(string[] usernames, string[] roleNames); + void DissociateRole(string username, string roleName); void DissociateRoles(string[] usernames, string[] roleNames); + void AssignRole(int memberId, string roleName); void AssignRoles(int[] memberIds, string[] roleNames); + void DissociateRole(int memberId, string roleName); void DissociateRoles(int[] memberIds, string[] roleNames); } } \ No newline at end of file diff --git a/src/Umbraco.Core/Services/MemberService.cs b/src/Umbraco.Core/Services/MemberService.cs index 128ccea5f7..44d7678f39 100644 --- a/src/Umbraco.Core/Services/MemberService.cs +++ b/src/Umbraco.Core/Services/MemberService.cs @@ -958,6 +958,10 @@ namespace Umbraco.Core.Services } } } + public void AssignRole(string username, string roleName) + { + AssignRoles(new[] { username }, new[] { roleName }); + } public void AssignRoles(string[] usernames, string[] roleNames) { @@ -968,6 +972,11 @@ namespace Umbraco.Core.Services } } + public void DissociateRole(string username, string roleName) + { + DissociateRoles(new[] { username }, new[] { roleName }); + } + public void DissociateRoles(string[] usernames, string[] roleNames) { var uow = _uowProvider.GetUnitOfWork(); @@ -976,6 +985,11 @@ namespace Umbraco.Core.Services repository.DissociateRoles(usernames, roleNames); } } + + public void AssignRole(int memberId, string roleName) + { + AssignRoles(new[] { memberId }, new[] { roleName }); + } public void AssignRoles(int[] memberIds, string[] roleNames) { @@ -986,6 +1000,11 @@ namespace Umbraco.Core.Services } } + public void DissociateRole(int memberId, string roleName) + { + DissociateRoles(new[] { memberId }, new[] { roleName }); + } + public void DissociateRoles(int[] memberIds, string[] roleNames) { var uow = _uowProvider.GetUnitOfWork(); From d9c66cd4b3c679b87e68cd6e5c77b949c3908984 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 2 Apr 2014 11:41:59 +0200 Subject: [PATCH 05/11] Adds AddRelation and missing events in RelationService from v7 into v6 --- src/Umbraco.Core/Services/IRelationService.cs | 8 ++ src/Umbraco.Core/Services/RelationService.cs | 135 +++++++++++++++++- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Services/IRelationService.cs b/src/Umbraco.Core/Services/IRelationService.cs index 32e7d88f2a..a219cfc43b 100644 --- a/src/Umbraco.Core/Services/IRelationService.cs +++ b/src/Umbraco.Core/Services/IRelationService.cs @@ -182,6 +182,14 @@ namespace Umbraco.Core.Services /// Returns True if any relations exists with the given Id, otherwise False bool IsRelated(int id); + /// + /// Checks whether two items are related + /// + /// Id of the Parent relation + /// Id of the Child relation + /// Returns True if any relations exists with the given Ids, otherwise False + bool AreRelated(int parentId, int childId); + /// /// Saves a /// diff --git a/src/Umbraco.Core/Services/RelationService.cs b/src/Umbraco.Core/Services/RelationService.cs index 5da9fddef0..5102731902 100644 --- a/src/Umbraco.Core/Services/RelationService.cs +++ b/src/Umbraco.Core/Services/RelationService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Persistence; @@ -326,14 +327,18 @@ namespace Umbraco.Core.Services Save(relationType); var relation = new Relation(parent.Id, child.Id, relationType); + if (SavingRelation.IsRaisedEventCancelled(new SaveEventArgs(relation), this)) + return relation; + var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationRepository(uow)) { repository.AddOrUpdate(relation); uow.Commit(); - - return relation; } + + SavedRelation.RaiseEvent(new SaveEventArgs(relation, false), this); + return relation; } /// @@ -350,14 +355,18 @@ namespace Umbraco.Core.Services throw new ArgumentNullException(string.Format("No RelationType with Alias '{0}' exists.", relationTypeAlias)); var relation = new Relation(parent.Id, child.Id, relationType); + if (SavingRelation.IsRaisedEventCancelled(new SaveEventArgs(relation), this)) + return relation; + var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationRepository(uow)) { repository.AddOrUpdate(relation); uow.Commit(); - - return relation; } + + SavedRelation.RaiseEvent(new SaveEventArgs(relation, false), this); + return relation; } /// @@ -388,18 +397,72 @@ namespace Umbraco.Core.Services } } + /// + /// Checks whether two items are related + /// + /// Id of the Parent relation + /// Id of the Child relation + /// Returns True if any relations exists with the given Ids, otherwise False + public bool AreRelated(int parentId, int childId) + { + using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork())) + { + var query = new Query().Where(x => x.ParentId == parentId && x.ChildId == childId); + return repository.GetByQuery(query).Any(); + } + } + + /// + /// Checks whether two items are related with a given relation type alias + /// + /// Id of the Parent relation + /// Id of the Child relation + /// Alias of the relation type + /// Returns True if any relations exists with the given Ids and relation type, otherwise False + public bool AreRelated(int parentId, int childId, string relationTypeAlias) + { + var relType = GetRelationTypeByAlias(relationTypeAlias); + if(relType == null) + return false; + + return AreRelated(parentId, childId, relType); + } + + + /// + /// Checks whether two items are related with a given relation type + /// + /// Id of the Parent relation + /// Id of the Child relation + /// Type of relation + /// Returns True if any relations exists with the given Ids and relation type, otherwise False + public bool AreRelated(int parentId, int childId, IRelationType relationType) + { + using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork())) + { + var query = new Query().Where(x => x.ParentId == parentId && x.ChildId == childId && x.RelationTypeId == relationType.Id); + return repository.GetByQuery(query).Any(); + } + } + + /// /// Saves a /// /// Relation to save public void Save(IRelation relation) { + if (SavingRelation.IsRaisedEventCancelled(new SaveEventArgs(relation), this)) + return; + var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationRepository(uow)) { repository.AddOrUpdate(relation); uow.Commit(); } + + SavedRelation.RaiseEvent(new SaveEventArgs(relation, false), this); } /// @@ -408,12 +471,17 @@ namespace Umbraco.Core.Services /// RelationType to Save public void Save(IRelationType relationType) { + if (SavingRelationType.IsRaisedEventCancelled(new SaveEventArgs(relationType), this)) + return; + var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationTypeRepository(uow)) { repository.AddOrUpdate(relationType); uow.Commit(); } + + SavedRelationType.RaiseEvent(new SaveEventArgs(relationType, false), this); } /// @@ -422,12 +490,17 @@ namespace Umbraco.Core.Services /// Relation to Delete public void Delete(IRelation relation) { + if (DeletingRelation.IsRaisedEventCancelled(new DeleteEventArgs(relation), this)) + return; + var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationRepository(uow)) { repository.Delete(relation); uow.Commit(); } + + DeletedRelation.RaiseEvent(new DeleteEventArgs(relation, false), this); } /// @@ -436,12 +509,17 @@ namespace Umbraco.Core.Services /// RelationType to Delete public void Delete(IRelationType relationType) { + if (DeletingRelationType.IsRaisedEventCancelled(new DeleteEventArgs(relationType), this)) + return; + var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationTypeRepository(uow)) { repository.Delete(relationType); uow.Commit(); } + + DeletedRelationType.RaiseEvent(new DeleteEventArgs(relationType, false), this); } /// @@ -450,18 +528,21 @@ namespace Umbraco.Core.Services /// to Delete Relations for public void DeleteRelationsOfType(IRelationType relationType) { + var relations = new List(); var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateRelationRepository(uow)) { var query = new Query().Where(x => x.RelationTypeId == relationType.Id); - var list = repository.GetByQuery(query).ToList(); + relations.AddRange(repository.GetByQuery(query).ToList()); - foreach (var relation in list) + foreach (var relation in relations) { repository.Delete(relation); } uow.Commit(); } + + DeletedRelation.RaiseEvent(new DeleteEventArgs(relations, false), this); } #region Private Methods @@ -480,5 +561,47 @@ namespace Umbraco.Core.Services return relations; } #endregion + + #region Events Handlers + /// + /// Occurs before Deleting a Relation + /// + public static event TypedEventHandler> DeletingRelation; + + /// + /// Occurs after a Relation is Deleted + /// + public static event TypedEventHandler> DeletedRelation; + + /// + /// Occurs before Saving a Relation + /// + public static event TypedEventHandler> SavingRelation; + + /// + /// Occurs after a Relation is Saved + /// + public static event TypedEventHandler> SavedRelation; + + /// + /// Occurs before Deleting a RelationType + /// + public static event TypedEventHandler> DeletingRelationType; + + /// + /// Occurs after a RelationType is Deleted + /// + public static event TypedEventHandler> DeletedRelationType; + + /// + /// Occurs before Saving a RelationType + /// + public static event TypedEventHandler> SavingRelationType; + + /// + /// Occurs after a RelationType is Saved + /// + public static event TypedEventHandler> SavedRelationType; + #endregion } } \ No newline at end of file From a768fe5bb3fb0fa623f8b644dee789fd6bb5695c Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 2 Apr 2014 11:42:48 +0200 Subject: [PATCH 06/11] Ports behaviour from membershiphelper from v7 to 6 to make them the same --- src/Umbraco.Web/Security/MembershipHelper.cs | 33 ++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Security/MembershipHelper.cs b/src/Umbraco.Web/Security/MembershipHelper.cs index 4572026938..d1db014436 100644 --- a/src/Umbraco.Web/Security/MembershipHelper.cs +++ b/src/Umbraco.Web/Security/MembershipHelper.cs @@ -276,8 +276,15 @@ namespace Umbraco.Web.Security { var membershipUser = provider.GetCurrentUser(); var member = GetCurrentMember(); - //this shouldn't happen - if (member == null) return null; + //this shouldn't happen but will if the member is deleted in the back office while the member is trying + // to use the front-end! + if (member == null) + { + //log them out since they've been removed + FormsAuthentication.SignOut(); + + return null; + } var model = ProfileModel.CreateModel(); model.Name = member.Name; @@ -416,8 +423,15 @@ namespace Umbraco.Web.Security if (provider.IsUmbracoMembershipProvider()) { var member = GetCurrentMember(); - //this shouldn't happen - if (member == null) return model; + //this shouldn't happen but will if the member is deleted in the back office while the member is trying + // to use the front-end! + if (member == null) + { + //log them out since they've been removed + FormsAuthentication.SignOut(); + model.IsLoggedIn = false; + return model; + } model.Name = member.Name; model.Username = member.Username; model.Email = member.Email; @@ -425,8 +439,15 @@ namespace Umbraco.Web.Security else { var member = provider.GetCurrentUser(); - //this shouldn't happen - if (member == null) return null; + //this shouldn't happen but will if the member is deleted in the back office while the member is trying + // to use the front-end! + if (member == null) + { + //log them out since they've been removed + FormsAuthentication.SignOut(); + model.IsLoggedIn = false; + return model; + } model.Name = member.UserName; model.Username = member.UserName; model.Email = member.Email; From 53c0bd6938f345ad9f1cd8892af3ae83553e1d94 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 2 Apr 2014 11:59:16 +0200 Subject: [PATCH 07/11] Fixes: Password is not saved when using the Register snippet --- src/Umbraco.Web/Controllers/UmbRegisterController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Umbraco.Web/Controllers/UmbRegisterController.cs b/src/Umbraco.Web/Controllers/UmbRegisterController.cs index dea1135131..aafa6fe0db 100644 --- a/src/Umbraco.Web/Controllers/UmbRegisterController.cs +++ b/src/Umbraco.Web/Controllers/UmbRegisterController.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Web.Mvc; using System.Web.Security; +using System.Web.Services.Description; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.member; using Umbraco.Core; @@ -24,6 +25,11 @@ namespace Umbraco.Web.Controllers MembershipCreateStatus status; var member = Members.RegisterMember(model, out status, model.LoginOnSuccess); + // Save the password + var memberService = Services.MemberService; + var m = memberService.GetByUsername(member.UserName); + memberService.SavePassword(m, model.Password); + switch (status) { case MembershipCreateStatus.Success: From 8371105c10927827b7ce39e31dfde9abc8f05868 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 2 Apr 2014 16:00:08 +0200 Subject: [PATCH 08/11] U4-4575 - property converters use wrong source value --- src/Umbraco.Web/Models/PublishedProperty.cs | 75 +++++++++++++++++++ .../PublishedCache/MemberPublishedContent.cs | 13 +--- src/Umbraco.Web/Umbraco.Web.csproj | 3 +- 3 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 src/Umbraco.Web/Models/PublishedProperty.cs diff --git a/src/Umbraco.Web/Models/PublishedProperty.cs b/src/Umbraco.Web/Models/PublishedProperty.cs new file mode 100644 index 0000000000..65430ba5f6 --- /dev/null +++ b/src/Umbraco.Web/Models/PublishedProperty.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using Umbraco.Core; +using Umbraco.Core.Models; +using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Services; + +namespace Umbraco.Web.Models +{ + public static class PublishedProperty + { + /// + /// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType. + /// + /// The published property types. + /// The properties. + /// A mapping function. + /// A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType + /// and taking values from the collection of Property. + /// Ensures that all conversions took place correctly. + internal static IEnumerable MapProperties( + IEnumerable propertyTypes, IEnumerable properties, + Func map) + { + var peResolver = DataTypesResolver.Current; + var dtService = ApplicationContext.Current.Services.DataTypeService; + return MapProperties(propertyTypes, properties, peResolver, dtService, map); + } + + /// + /// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType. + /// + /// The published property types. + /// The properties. + /// A mapping function. + /// A DataTypesResolver instance. + /// An IDataTypeService instance. + /// A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType + /// and taking values from the collection of Property. + /// Ensures that all conversions took place correctly. + internal static IEnumerable MapProperties( + IEnumerable propertyTypes, IEnumerable properties, + DataTypesResolver dataTypesResolver, IDataTypeService dataTypeService, + Func map) + { + return propertyTypes + .Select(x => + { + var p = properties.SingleOrDefault(xx => xx.Alias == x.PropertyTypeAlias); + var v = p == null || p.Value == null ? null : p.Value; + if (v != null) + { + var dataType = dataTypesResolver.DataTypes.SingleOrDefault(qq => qq.Id == x.PropertyEditorGuid); + if (dataType != null) + { + var data = dataType.Data; + data.Value = v; + var n = data.ToXMl(new XmlDocument()); + v = n.InnerXml; + } + } + // fixme - means that the IPropertyValueConverter will always get a string + // fixme and never an int or DateTime that's in the DB unless the value editor has + // fixme a way to say it's OK to use what's in the DB? + + return map(x, p, v); + }); + } + } +} diff --git a/src/Umbraco.Web/PublishedCache/MemberPublishedContent.cs b/src/Umbraco.Web/PublishedCache/MemberPublishedContent.cs index deafcaab40..e538d135d3 100644 --- a/src/Umbraco.Web/PublishedCache/MemberPublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/MemberPublishedContent.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache private readonly IMember _member; private readonly MembershipUser _membershipUser; - private readonly List _properties; + private readonly IPublishedProperty[] _properties; private readonly PublishedContentType _publishedMemberType; public MemberPublishedContent(IMember member, MembershipUser membershipUser) @@ -28,19 +28,14 @@ namespace Umbraco.Web.PublishedCache _member = member; _membershipUser = membershipUser; - _properties = new List(); _publishedMemberType = PublishedContentType.Get(PublishedItemType.Member, _member.ContentTypeAlias); if (_publishedMemberType == null) { throw new InvalidOperationException("Could not get member type with alias " + _member.ContentTypeAlias); } - foreach (var propType in _publishedMemberType.PropertyTypes) - { - var val = _member.Properties.Any(x => x.Alias == propType.PropertyTypeAlias) == false - ? string.Empty - : _member.Properties[propType.PropertyTypeAlias].Value; - _properties.Add(new RawValueProperty(propType, val ?? string.Empty)); - } + _properties = PublishedProperty.MapProperties(_publishedMemberType.PropertyTypes, _member.Properties, + (t, p, v) => new RawValueProperty(t, v ?? string.Empty)) + .ToArray(); } #region Membership provider member properties diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 22fd963203..581893f2ea 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1,4 +1,4 @@ - + @@ -300,6 +300,7 @@ + From 9940b78a57268c0a08353911f111b143546c754c Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 2 Apr 2014 17:00:24 +0200 Subject: [PATCH 09/11] U4-4575 - fix 8371105 --- src/Umbraco.Web/Models/PublishedProperty.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/Models/PublishedProperty.cs b/src/Umbraco.Web/Models/PublishedProperty.cs index 65430ba5f6..b24d1260a3 100644 --- a/src/Umbraco.Web/Models/PublishedProperty.cs +++ b/src/Umbraco.Web/Models/PublishedProperty.cs @@ -55,13 +55,20 @@ namespace Umbraco.Web.Models var v = p == null || p.Value == null ? null : p.Value; if (v != null) { - var dataType = dataTypesResolver.DataTypes.SingleOrDefault(qq => qq.Id == x.PropertyEditorGuid); + // note - not sure about the performance here + var dataTypeDefinition = global::umbraco.cms.businesslogic.datatype.DataTypeDefinition + .GetDataTypeDefinition(x.DataTypeId); + var dataType = dataTypeDefinition.DataType; if (dataType != null) { var data = dataType.Data; data.Value = v; var n = data.ToXMl(new XmlDocument()); - v = n.InnerXml; + if (n.NodeType == XmlNodeType.CDATA || n.NodeType == XmlNodeType.Text) + v = n.InnerText; + else if (n.NodeType == XmlNodeType.Element) + v = n.InnerXml; + // note - is there anything else we should take care of? } } // fixme - means that the IPropertyValueConverter will always get a string From bf8add4f8d75886043c202c4785c0c929217f489 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 3 Apr 2014 11:10:43 +0200 Subject: [PATCH 10/11] Manually picked up PR #343 --- src/Umbraco.Core/Services/IRelationService.cs | 47 +++++++++++++ src/Umbraco.Core/Services/RelationService.cs | 67 ++++++++++++++++++- 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Services/IRelationService.cs b/src/Umbraco.Core/Services/IRelationService.cs index a219cfc43b..73f8e7a88d 100644 --- a/src/Umbraco.Core/Services/IRelationService.cs +++ b/src/Umbraco.Core/Services/IRelationService.cs @@ -63,6 +63,21 @@ namespace Umbraco.Core.Services /// An enumerable list of objects IEnumerable GetByParentId(int id); + /// + /// Gets a list of objects by their parent entity + /// + /// Parent Entity to retrieve relations for + /// An enumerable list of objects + IEnumerable GetByParent(IUmbracoEntity parent); + + /// + /// Gets a list of objects by their parent entity + /// + /// Parent Entity to retrieve relations for + /// Alias of the type of relation to retrieve + /// An enumerable list of objects + IEnumerable GetByParent(IUmbracoEntity parent, string relationTypeAlias); + /// /// Gets a list of objects by their child Id /// @@ -70,6 +85,21 @@ namespace Umbraco.Core.Services /// An enumerable list of objects IEnumerable GetByChildId(int id); + /// + /// Gets a list of objects by their child Entity + /// + /// Child Entity to retrieve relations for + /// An enumerable list of objects + IEnumerable GetByChild(IUmbracoEntity child); + + /// + /// Gets a list of objects by their child Entity + /// + /// Child Entity to retrieve relations for + /// Alias of the type of relation to retrieve + /// An enumerable list of objects + IEnumerable GetByChild(IUmbracoEntity child, string relationTypeAlias); + /// /// Gets a list of objects by their child or parent Id. /// Using this method will get you all relations regards of it being a child or parent relation. @@ -190,6 +220,23 @@ namespace Umbraco.Core.Services /// Returns True if any relations exists with the given Ids, otherwise False bool AreRelated(int parentId, int childId); + /// + /// Checks whether two items are related + /// + /// Parent entity + /// Child entity + /// Returns True if any relations exist between the entities, otherwise False + bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child); + + /// + /// Checks whether two items are related + /// + /// Parent entity + /// Child entity + /// Alias of the type of relation to create + /// Returns True if any relations exist between the entities, otherwise False + bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias); + /// /// Saves a /// diff --git a/src/Umbraco.Core/Services/RelationService.cs b/src/Umbraco.Core/Services/RelationService.cs index 5102731902..bd4a46c75e 100644 --- a/src/Umbraco.Core/Services/RelationService.cs +++ b/src/Umbraco.Core/Services/RelationService.cs @@ -128,6 +128,27 @@ namespace Umbraco.Core.Services } } + /// + /// Gets a list of objects by their parent entity + /// + /// Parent Entity to retrieve relations for + /// An enumerable list of objects + public IEnumerable GetByParent(IUmbracoEntity parent) + { + return GetByParentId(parent.Id); + } + + /// + /// Gets a list of objects by their parent entity + /// + /// Parent Entity to retrieve relations for + /// Alias of the type of relation to retrieve + /// An enumerable list of objects + public IEnumerable GetByParent(IUmbracoEntity parent, string relationTypeAlias) + { + return GetByParent(parent).Where(relation => relation.RelationType.Alias == relationTypeAlias); + } + /// /// Gets a list of objects by their child Id /// @@ -142,6 +163,27 @@ namespace Umbraco.Core.Services } } + /// + /// Gets a list of objects by their child Entity + /// + /// Child Entity to retrieve relations for + /// An enumerable list of objects + public IEnumerable GetByChild(IUmbracoEntity child) + { + return GetByChildId(child.Id); + } + + /// + /// Gets a list of objects by their child Entity + /// + /// Child Entity to retrieve relations for + /// Alias of the type of relation to retrieve + /// An enumerable list of objects + public IEnumerable GetByChild(IUmbracoEntity child, string relationTypeAlias) + { + return GetByChild(child).Where(relation => relation.RelationType.Alias == relationTypeAlias); + } + /// /// Gets a list of objects by their child or parent Id. /// Using this method will get you all relations regards of it being a child or parent relation. @@ -422,7 +464,7 @@ namespace Umbraco.Core.Services public bool AreRelated(int parentId, int childId, string relationTypeAlias) { var relType = GetRelationTypeByAlias(relationTypeAlias); - if(relType == null) + if (relType == null) return false; return AreRelated(parentId, childId, relType); @@ -445,6 +487,29 @@ namespace Umbraco.Core.Services } } + /// + /// Checks whether two items are related + /// + /// Parent entity + /// Child entity + /// Returns True if any relations exist between the entities, otherwise False + public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child) + { + return AreRelated(parent.Id, child.Id); + } + + /// + /// Checks whether two items are related + /// + /// Parent entity + /// Child entity + /// Alias of the type of relation to create + /// Returns True if any relations exist between the entities, otherwise False + public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias) + { + return AreRelated(parent.Id, child.Id, relationTypeAlias); + } + /// /// Saves a From 4a516f7da96c414c6028aad302ae92b95d03e7f1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 7 Apr 2014 13:01:43 +0200 Subject: [PATCH 11/11] Manually applying PR #347 --- .../umbraco/dialogs/protectPage.aspx.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs index c658db703f..de6e15569e 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs @@ -1,5 +1,6 @@ using System; using System.Globalization; +using System.Linq; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; @@ -32,10 +33,10 @@ namespace umbraco.presentation.umbraco.dialogs protected ContentPicker errorPagePicker = new ContentPicker(); override protected void OnInit(EventArgs e) - { + { base.OnInit(e); } - + protected void selectMode(object sender, EventArgs e) { p_mode.Visible = false; @@ -111,7 +112,7 @@ namespace umbraco.presentation.umbraco.dialogs SimpleLoginLabel.Visible = true; SimpleLoginLabel.Text = m.UserName; pane_advanced.Visible = false; - bt_protect.CommandName = "simple"; + bt_protect.CommandName = "simple"; } } @@ -131,9 +132,9 @@ namespace umbraco.presentation.umbraco.dialogs _memberGroups.ID = "Membergroups"; _memberGroups.Width = 175; var selectedGroups = ""; - var roles = Roles.GetAllRoles(); + var roles = Roles.GetAllRoles().OrderBy(x => x); - if (roles.Length > 0) + if (roles.Any()) { foreach (string role in roles) { @@ -185,7 +186,7 @@ namespace umbraco.presentation.umbraco.dialogs if (Page.IsValid) { int pageId = int.Parse(helper.Request("nodeId")); - + if (e.CommandName == "simple") { var memberLogin = simpleLogin.Visible ? simpleLogin.Text : SimpleLoginLabel.Text; @@ -222,7 +223,7 @@ namespace umbraco.presentation.umbraco.dialogs } else if (pp_pass.Visible) { - SimpleLoginNameValidator.IsValid = false; + SimpleLoginNameValidator.IsValid = false; SimpleLoginLabel.Visible = true; SimpleLoginLabel.Text = memberLogin; simpleLogin.Visible = false; @@ -567,6 +568,6 @@ namespace umbraco.presentation.umbraco.dialogs /// protected global::System.Web.UI.WebControls.PlaceHolder js; - + } }