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/IRelationService.cs b/src/Umbraco.Core/Services/IRelationService.cs index 32e7d88f2a..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. @@ -182,6 +212,31 @@ 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); + + /// + /// 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/MemberService.cs b/src/Umbraco.Core/Services/MemberService.cs index 33b7721556..44d7678f39 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; } /// @@ -955,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) { @@ -965,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(); @@ -973,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) { @@ -983,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(); diff --git a/src/Umbraco.Core/Services/RelationService.cs b/src/Umbraco.Core/Services/RelationService.cs index 5da9fddef0..bd4a46c75e 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; @@ -127,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 /// @@ -141,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. @@ -326,14 +369,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 +397,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 +439,95 @@ 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(); + } + } + + /// + /// 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 /// /// 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 +536,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 +555,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 +574,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 +593,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 +626,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 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"/> 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 @@ + + + + + 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: diff --git a/src/Umbraco.Web/Models/PublishedProperty.cs b/src/Umbraco.Web/Models/PublishedProperty.cs new file mode 100644 index 0000000000..b24d1260a3 --- /dev/null +++ b/src/Umbraco.Web/Models/PublishedProperty.cs @@ -0,0 +1,82 @@ +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) + { + // 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()); + 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 + // 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/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; 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 @@ + 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; - + } }