Merge remote-tracking branch 'origin/6.2.0' into 6.2-cachefixing
This commit is contained in:
@@ -14,9 +14,13 @@ namespace Umbraco.Core.Services
|
||||
IEnumerable<T> GetMembersInRole(string roleName);
|
||||
IEnumerable<T> 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);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,21 @@ namespace Umbraco.Core.Services
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
IEnumerable<IRelation> GetByParentId(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their parent entity
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent Entity to retrieve relations for</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
IEnumerable<IRelation> GetByParent(IUmbracoEntity parent);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their parent entity
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent Entity to retrieve relations for</param>
|
||||
/// <param name="relationTypeAlias">Alias of the type of relation to retrieve</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
IEnumerable<IRelation> GetByParent(IUmbracoEntity parent, string relationTypeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their child Id
|
||||
/// </summary>
|
||||
@@ -70,6 +85,21 @@ namespace Umbraco.Core.Services
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
IEnumerable<IRelation> GetByChildId(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their child Entity
|
||||
/// </summary>
|
||||
/// <param name="child">Child Entity to retrieve relations for</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
IEnumerable<IRelation> GetByChild(IUmbracoEntity child);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their child Entity
|
||||
/// </summary>
|
||||
/// <param name="child">Child Entity to retrieve relations for</param>
|
||||
/// <param name="relationTypeAlias">Alias of the type of relation to retrieve</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
IEnumerable<IRelation> GetByChild(IUmbracoEntity child, string relationTypeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> 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>Returns <c>True</c> if any relations exists with the given Id, otherwise <c>False</c></returns>
|
||||
bool IsRelated(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related
|
||||
/// </summary>
|
||||
/// <param name="parentId">Id of the Parent relation</param>
|
||||
/// <param name="childId">Id of the Child relation</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exists with the given Ids, otherwise <c>False</c></returns>
|
||||
bool AreRelated(int parentId, int childId);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent entity</param>
|
||||
/// <param name="child">Child entity</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exist between the entities, otherwise <c>False</c></returns>
|
||||
bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent entity</param>
|
||||
/// <param name="child">Child entity</param>
|
||||
/// <param name="relationTypeAlias">Alias of the type of relation to create</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exist between the entities, otherwise <c>False</c></returns>
|
||||
bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a <see cref="Relation"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their parent entity
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent Entity to retrieve relations for</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
public IEnumerable<IRelation> GetByParent(IUmbracoEntity parent)
|
||||
{
|
||||
return GetByParentId(parent.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their parent entity
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent Entity to retrieve relations for</param>
|
||||
/// <param name="relationTypeAlias">Alias of the type of relation to retrieve</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
public IEnumerable<IRelation> GetByParent(IUmbracoEntity parent, string relationTypeAlias)
|
||||
{
|
||||
return GetByParent(parent).Where(relation => relation.RelationType.Alias == relationTypeAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their child Id
|
||||
/// </summary>
|
||||
@@ -141,6 +163,27 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their child Entity
|
||||
/// </summary>
|
||||
/// <param name="child">Child Entity to retrieve relations for</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
public IEnumerable<IRelation> GetByChild(IUmbracoEntity child)
|
||||
{
|
||||
return GetByChildId(child.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> objects by their child Entity
|
||||
/// </summary>
|
||||
/// <param name="child">Child Entity to retrieve relations for</param>
|
||||
/// <param name="relationTypeAlias">Alias of the type of relation to retrieve</param>
|
||||
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
|
||||
public IEnumerable<IRelation> GetByChild(IUmbracoEntity child, string relationTypeAlias)
|
||||
{
|
||||
return GetByChild(child).Where(relation => relation.RelationType.Alias == relationTypeAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of <see cref="Relation"/> 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<IRelation>(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<IRelation>(relation, false), this);
|
||||
return relation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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<IRelation>(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<IRelation>(relation, false), this);
|
||||
return relation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -388,18 +439,95 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related
|
||||
/// </summary>
|
||||
/// <param name="parentId">Id of the Parent relation</param>
|
||||
/// <param name="childId">Id of the Child relation</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exists with the given Ids, otherwise <c>False</c></returns>
|
||||
public bool AreRelated(int parentId, int childId)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
var query = new Query<IRelation>().Where(x => x.ParentId == parentId && x.ChildId == childId);
|
||||
return repository.GetByQuery(query).Any();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related with a given relation type alias
|
||||
/// </summary>
|
||||
/// <param name="parentId">Id of the Parent relation</param>
|
||||
/// <param name="childId">Id of the Child relation</param>
|
||||
/// <param name="relationTypeAlias">Alias of the relation type</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exists with the given Ids and relation type, otherwise <c>False</c></returns>
|
||||
public bool AreRelated(int parentId, int childId, string relationTypeAlias)
|
||||
{
|
||||
var relType = GetRelationTypeByAlias(relationTypeAlias);
|
||||
if (relType == null)
|
||||
return false;
|
||||
|
||||
return AreRelated(parentId, childId, relType);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related with a given relation type
|
||||
/// </summary>
|
||||
/// <param name="parentId">Id of the Parent relation</param>
|
||||
/// <param name="childId">Id of the Child relation</param>
|
||||
/// <param name="relationTypeAlias">Type of relation</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exists with the given Ids and relation type, otherwise <c>False</c></returns>
|
||||
public bool AreRelated(int parentId, int childId, IRelationType relationType)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
var query = new Query<IRelation>().Where(x => x.ParentId == parentId && x.ChildId == childId && x.RelationTypeId == relationType.Id);
|
||||
return repository.GetByQuery(query).Any();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent entity</param>
|
||||
/// <param name="child">Child entity</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exist between the entities, otherwise <c>False</c></returns>
|
||||
public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child)
|
||||
{
|
||||
return AreRelated(parent.Id, child.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two items are related
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent entity</param>
|
||||
/// <param name="child">Child entity</param>
|
||||
/// <param name="relationTypeAlias">Alias of the type of relation to create</param>
|
||||
/// <returns>Returns <c>True</c> if any relations exist between the entities, otherwise <c>False</c></returns>
|
||||
public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias)
|
||||
{
|
||||
return AreRelated(parent.Id, child.Id, relationTypeAlias);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Saves a <see cref="Relation"/>
|
||||
/// </summary>
|
||||
/// <param name="relation">Relation to save</param>
|
||||
public void Save(IRelation relation)
|
||||
{
|
||||
if (SavingRelation.IsRaisedEventCancelled(new SaveEventArgs<IRelation>(relation), this))
|
||||
return;
|
||||
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateRelationRepository(uow))
|
||||
{
|
||||
repository.AddOrUpdate(relation);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
SavedRelation.RaiseEvent(new SaveEventArgs<IRelation>(relation, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -408,12 +536,17 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="relationType">RelationType to Save</param>
|
||||
public void Save(IRelationType relationType)
|
||||
{
|
||||
if (SavingRelationType.IsRaisedEventCancelled(new SaveEventArgs<IRelationType>(relationType), this))
|
||||
return;
|
||||
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateRelationTypeRepository(uow))
|
||||
{
|
||||
repository.AddOrUpdate(relationType);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
SavedRelationType.RaiseEvent(new SaveEventArgs<IRelationType>(relationType, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -422,12 +555,17 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="relation">Relation to Delete</param>
|
||||
public void Delete(IRelation relation)
|
||||
{
|
||||
if (DeletingRelation.IsRaisedEventCancelled(new DeleteEventArgs<IRelation>(relation), this))
|
||||
return;
|
||||
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateRelationRepository(uow))
|
||||
{
|
||||
repository.Delete(relation);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
DeletedRelation.RaiseEvent(new DeleteEventArgs<IRelation>(relation, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -436,12 +574,17 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="relationType">RelationType to Delete</param>
|
||||
public void Delete(IRelationType relationType)
|
||||
{
|
||||
if (DeletingRelationType.IsRaisedEventCancelled(new DeleteEventArgs<IRelationType>(relationType), this))
|
||||
return;
|
||||
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateRelationTypeRepository(uow))
|
||||
{
|
||||
repository.Delete(relationType);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
DeletedRelationType.RaiseEvent(new DeleteEventArgs<IRelationType>(relationType, false), this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -450,18 +593,21 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="relationType"><see cref="RelationType"/> to Delete Relations for</param>
|
||||
public void DeleteRelationsOfType(IRelationType relationType)
|
||||
{
|
||||
var relations = new List<IRelation>();
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var repository = _repositoryFactory.CreateRelationRepository(uow))
|
||||
{
|
||||
var query = new Query<IRelation>().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<IRelation>(relations, false), this);
|
||||
}
|
||||
|
||||
#region Private Methods
|
||||
@@ -480,5 +626,47 @@ namespace Umbraco.Core.Services
|
||||
return relations;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events Handlers
|
||||
/// <summary>
|
||||
/// Occurs before Deleting a Relation
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelation>> DeletingRelation;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after a Relation is Deleted
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelation>> DeletedRelation;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Saving a Relation
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelation>> SavingRelation;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after a Relation is Saved
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelation>> SavedRelation;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Deleting a RelationType
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelationType>> DeletingRelationType;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after a RelationType is Deleted
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelationType>> DeletedRelationType;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Saving a RelationType
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelationType>> SavingRelationType;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after a RelationType is Saved
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelationType>> SavedRelationType;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ More information and documentation can be found on CodePlex: http://umbracoexami
|
||||
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
|
||||
|
||||
<add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
|
||||
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcards="true"/>
|
||||
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/>
|
||||
|
||||
</providers>
|
||||
</ExamineSearchProviders>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
<!-- default external indexer, which excludes protected and unpublished pages-->
|
||||
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>
|
||||
|
||||
<!-- default external indexer, which excludes protected and unpublished pages-->
|
||||
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>
|
||||
|
||||
</providers>
|
||||
</ExamineIndexProviders>
|
||||
|
||||
@@ -29,11 +29,11 @@ More information and documentation can be found on CodePlex: http://umbracoexami
|
||||
<providers>
|
||||
<add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
|
||||
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
|
||||
|
||||
|
||||
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
|
||||
|
||||
|
||||
<add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
|
||||
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcards="true"/>
|
||||
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/>
|
||||
|
||||
</providers>
|
||||
</ExamineSearchProviders>
|
||||
|
||||
@@ -275,6 +275,11 @@
|
||||
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="1.4.5.0-1.4.6.0" newVersion="1.4.6.0" />
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
82
src/Umbraco.Web/Models/PublishedProperty.cs
Normal file
82
src/Umbraco.Web/Models/PublishedProperty.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType.
|
||||
/// </summary>
|
||||
/// <param name="propertyTypes">The published property types.</param>
|
||||
/// <param name="properties">The properties.</param>
|
||||
/// <param name="map">A mapping function.</param>
|
||||
/// <returns>A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType
|
||||
/// and taking values from the collection of Property.</returns>
|
||||
/// <remarks>Ensures that all conversions took place correctly.</remarks>
|
||||
internal static IEnumerable<IPublishedProperty> MapProperties(
|
||||
IEnumerable<PublishedPropertyType> propertyTypes, IEnumerable<Property> properties,
|
||||
Func<PublishedPropertyType, Property, object, IPublishedProperty> map)
|
||||
{
|
||||
var peResolver = DataTypesResolver.Current;
|
||||
var dtService = ApplicationContext.Current.Services.DataTypeService;
|
||||
return MapProperties(propertyTypes, properties, peResolver, dtService, map);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType.
|
||||
/// </summary>
|
||||
/// <param name="propertyTypes">The published property types.</param>
|
||||
/// <param name="properties">The properties.</param>
|
||||
/// <param name="map">A mapping function.</param>
|
||||
/// <param name="dataTypesResolver">A DataTypesResolver instance.</param>
|
||||
/// <param name="dataTypeService">An IDataTypeService instance.</param>
|
||||
/// <returns>A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType
|
||||
/// and taking values from the collection of Property.</returns>
|
||||
/// <remarks>Ensures that all conversions took place correctly.</remarks>
|
||||
internal static IEnumerable<IPublishedProperty> MapProperties(
|
||||
IEnumerable<PublishedPropertyType> propertyTypes, IEnumerable<Property> properties,
|
||||
DataTypesResolver dataTypesResolver, IDataTypeService dataTypeService,
|
||||
Func<PublishedPropertyType, Property, object, IPublishedProperty> 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
|
||||
private readonly IMember _member;
|
||||
private readonly MembershipUser _membershipUser;
|
||||
private readonly List<IPublishedProperty> _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<IPublishedProperty>();
|
||||
_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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
@@ -300,6 +300,7 @@
|
||||
<Compile Include="Models\ChangingPasswordModel.cs" />
|
||||
<Compile Include="Models\IRenderModel.cs" />
|
||||
<Compile Include="Models\PostRedirectModel.cs" />
|
||||
<Compile Include="Models\PublishedProperty.cs" />
|
||||
<Compile Include="Mvc\RedirectToUmbracoUrlResult.cs" />
|
||||
<Compile Include="PublishedCache\MemberPublishedContent.cs" />
|
||||
<Compile Include="PublishedCache\RawValueProperty.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
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder js;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user