Fixes: U4-4005 Member custom properties not saving from code, only from backend, wraps more of the getter functions in legacy member class with new member service methods, fixes paged result method when there are no results.
This commit is contained in:
@@ -151,6 +151,21 @@ namespace Umbraco.Core.Persistence.Caching
|
||||
_keyTracker.Remove(key);
|
||||
}
|
||||
|
||||
public void Delete(Type type, int entityId)
|
||||
{
|
||||
var key = GetCompositeId(type, entityId);
|
||||
if (_memoryCache != null)
|
||||
{
|
||||
_memoryCache.Remove(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpRuntime.Cache.Remove(key);
|
||||
}
|
||||
|
||||
_keyTracker.Remove(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear cache by type
|
||||
/// </summary>
|
||||
|
||||
@@ -512,6 +512,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
totalRecords = Convert.ToInt32(pagedResult.TotalItems);
|
||||
|
||||
//now that we have the member dto's we need to construct true members from the list.
|
||||
if (totalRecords == 0)
|
||||
{
|
||||
return Enumerable.Empty<IMember>();
|
||||
}
|
||||
var result = GetAll(pagedResult.Items.Select(x => x.NodeId).ToArray());
|
||||
|
||||
//now we need to ensure this result is also ordered by the same order by clause
|
||||
|
||||
@@ -298,6 +298,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
totalRecords = Convert.ToInt32(pagedResult.TotalItems);
|
||||
|
||||
//now that we have the user dto's we need to construct true members from the list.
|
||||
if (totalRecords == 0)
|
||||
{
|
||||
return Enumerable.Empty<IUser>();
|
||||
}
|
||||
|
||||
var result = GetAll(pagedResult.Items.Select(x => x.Id).ToArray());
|
||||
|
||||
//now we need to ensure this result is also ordered by the same order by clause
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Umbraco.Core.Services
|
||||
using (var uow = _uowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = _repositoryFactory.CreateMemberRepository(uow);
|
||||
//NOTE What about content that has the contenttype as part of its composition?
|
||||
//TODO: What about content that has the contenttype as part of its composition?
|
||||
var query = Query<IMember>.Builder.Where(x => x.ContentTypeId == memberTypeId);
|
||||
var members = repository.GetByQuery(query).ToArray();
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using umbraco.interfaces;
|
||||
|
||||
@@ -50,6 +52,8 @@ namespace Umbraco.Web.Cache
|
||||
ClearCacheByKeySearch(string.Format("{0}_{1}", CacheKeys.MemberLibraryCacheKey, id));
|
||||
ApplicationContext.Current.ApplicationCache.
|
||||
ClearCacheByKeySearch(string.Format("{0}{1}", CacheKeys.MemberBusinessLogicCacheKey, id));
|
||||
|
||||
RuntimeCacheProvider.Current.Delete(typeof(IMember), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
@@ -11,6 +12,7 @@ using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using umbraco.cms.businesslogic.cache;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
@@ -63,6 +65,12 @@ namespace umbraco.cms.businesslogic.member
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal Member(IMember member)
|
||||
: base(member)
|
||||
{
|
||||
SetupNode(member);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Member class.
|
||||
/// </summary>
|
||||
@@ -103,20 +111,10 @@ namespace umbraco.cms.businesslogic.member
|
||||
|
||||
public static IEnumerable<Member> GetAllAsList()
|
||||
{
|
||||
var tmp = new List<Member>();
|
||||
using (var dr = SqlHelper.ExecuteReader(
|
||||
string.Format(_sQLOptimizedMany.Trim(), "1=1", "umbracoNode.text"),
|
||||
SqlHelper.CreateParameter("@nodeObjectType", Member._objectType)))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
var m = new Member(dr.GetInt("id"), true);
|
||||
m.PopulateMemberFromReader(dr);
|
||||
tmp.Add(m);
|
||||
}
|
||||
}
|
||||
|
||||
return tmp.ToArray();
|
||||
int totalRecs;
|
||||
return ApplicationContext.Current.Services.MemberService.GetAllMembers(0, int.MaxValue, out totalRecs)
|
||||
.Select(x => new Member(x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -149,7 +147,11 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <returns></returns>
|
||||
public static Member[] getMemberFromFirstLetter(char letter)
|
||||
{
|
||||
return GetMemberByName(letter.ToString(), true);
|
||||
int totalRecs;
|
||||
return ApplicationContext.Current.Services.MemberService.FindMembersByUsername(
|
||||
letter.ToString(CultureInfo.InvariantCulture), 0, int.MaxValue, out totalRecs, StringPropertyMatchType.StartsWith)
|
||||
.Select(x => new Member(x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public static Member[] GetMemberByName(string usernameToMatch, bool matchByNameInsteadOfLogin)
|
||||
@@ -214,7 +216,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
{
|
||||
if (mbt == null) throw new ArgumentNullException("mbt");
|
||||
|
||||
var loginName = (!string.IsNullOrEmpty(LoginName)) ? LoginName : Name;
|
||||
var loginName = (string.IsNullOrEmpty(LoginName) == false) ? LoginName : Name;
|
||||
|
||||
if (string.IsNullOrEmpty(loginName))
|
||||
throw new ArgumentException("The loginname must be different from an empty string", "loginName");
|
||||
@@ -267,27 +269,12 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <returns>The member with the specified loginname - null if no Member with the login exists</returns>
|
||||
public static Member GetMemberFromLoginName(string loginName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(loginName))
|
||||
throw new ArgumentException("The username of a Member must be different from an emptry string", "loginName");
|
||||
if (IsMember(loginName))
|
||||
{
|
||||
var o = SqlHelper.ExecuteScalar<object>(
|
||||
"select nodeID from cmsMember where LoginName = @loginName",
|
||||
SqlHelper.CreateParameter("@loginName", loginName));
|
||||
Mandate.ParameterNotNullOrEmpty(loginName, "loginName");
|
||||
|
||||
if (o == null)
|
||||
return null;
|
||||
var found = ApplicationContext.Current.Services.MemberService.GetByUsername(loginName);
|
||||
if (found == null) return null;
|
||||
|
||||
int tmpId;
|
||||
if (!int.TryParse(o.ToString(), out tmpId))
|
||||
return null;
|
||||
|
||||
return new Member(tmpId);
|
||||
}
|
||||
else
|
||||
HttpContext.Current.Trace.Warn("No member with loginname: " + loginName + " Exists");
|
||||
|
||||
return null;
|
||||
return new Member(found);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -302,18 +289,10 @@ namespace umbraco.cms.businesslogic.member
|
||||
if (string.IsNullOrEmpty(email))
|
||||
return null;
|
||||
|
||||
var o = SqlHelper.ExecuteScalar<object>(
|
||||
"select nodeID from cmsMember where Email = @email",
|
||||
SqlHelper.CreateParameter("@email", email.ToLower()));
|
||||
var found = ApplicationContext.Current.Services.MemberService.GetByEmail(email);
|
||||
if (found == null) return null;
|
||||
|
||||
if (o == null)
|
||||
return null;
|
||||
|
||||
int tmpId;
|
||||
if (!int.TryParse(o.ToString(), out tmpId))
|
||||
return null;
|
||||
|
||||
return new Member(tmpId);
|
||||
return new Member(found);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,21 +307,11 @@ namespace umbraco.cms.businesslogic.member
|
||||
if (string.IsNullOrEmpty(email))
|
||||
return null;
|
||||
|
||||
var tmp = new List<Member>();
|
||||
using (var dr = SqlHelper.ExecuteReader(string.Format(_sQLOptimizedMany.Trim(),
|
||||
"Email = @email",
|
||||
"umbracoNode.text"),
|
||||
SqlHelper.CreateParameter("@nodeObjectType", Member._objectType),
|
||||
SqlHelper.CreateParameter("@email", email.ToLower())))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
var m = new Member(dr.GetInt("id"), true);
|
||||
m.PopulateMemberFromReader(dr);
|
||||
tmp.Add(m);
|
||||
}
|
||||
}
|
||||
return tmp.ToArray();
|
||||
int totalRecs;
|
||||
var found = ApplicationContext.Current.Services.MemberService.FindMembersByEmail(
|
||||
email, 0, int.MaxValue, out totalRecs, StringPropertyMatchType.Exact);
|
||||
|
||||
return found.Select(x => new Member(x)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -425,16 +394,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <param name="dt">The membertype which are being deleted</param>
|
||||
public static void DeleteFromType(MemberType dt)
|
||||
{
|
||||
var objs = getContentOfContentType(dt);
|
||||
foreach (var c in objs)
|
||||
{
|
||||
// due to recursive structure document might already been deleted..
|
||||
if (IsNode(c.UniqueId))
|
||||
{
|
||||
var tmp = new Member(c.UniqueId);
|
||||
tmp.delete();
|
||||
}
|
||||
}
|
||||
ApplicationContext.Current.Services.MemberService.DeleteMembersOfType(dt.Id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -766,13 +726,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <returns></returns>
|
||||
public string GetPassword()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_password))
|
||||
{
|
||||
_password = SqlHelper.ExecuteScalar<string>(
|
||||
"select Password from cmsMember where nodeId = @id",
|
||||
SqlHelper.CreateParameter("@id", Id));
|
||||
}
|
||||
return _password;
|
||||
return Content.Password;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1113,19 +1067,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
|
||||
return HttpContext.Current.User.Identity.IsAuthenticated;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Make a lookup in the database to verify if a member truely exists
|
||||
/// </summary>
|
||||
/// <param name="nodeId">The node id of the member</param>
|
||||
/// <returns>True is a record exists in db</returns>
|
||||
private static bool MemberExists(int nodeId)
|
||||
{
|
||||
return ApplicationContext.Current.Services.MemberService.Exists(nodeId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current visitors memberid
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user