diff --git a/src/UmbracoExamine/BaseUmbracoIndexer.cs b/src/UmbracoExamine/BaseUmbracoIndexer.cs
index 1d87b0dfff..bd480b88f1 100644
--- a/src/UmbracoExamine/BaseUmbracoIndexer.cs
+++ b/src/UmbracoExamine/BaseUmbracoIndexer.cs
@@ -150,7 +150,7 @@ namespace UmbracoExamine
{
//By default, we will be using the UmbracoDataService
//generally this would only need to be set differently for unit testing
- DataService = new UmbracoDataService();
+ DataService = CreateDefaultUmbracoDataService();
}
DataService.LogService.LogLevel = LoggingLevel.Normal;
@@ -206,10 +206,15 @@ namespace UmbracoExamine
}
}
- }
-
+ }
+
#endregion
+ protected virtual IDataService CreateDefaultUmbracoDataService()
+ {
+ return new UmbracoDataService();
+ }
+
///
/// Used to aquire the internal searcher
///
diff --git a/src/UmbracoExamine/DataServices/UmbracoContentService.cs b/src/UmbracoExamine/DataServices/UmbracoContentService.cs
index b52f60a2f2..5dcaabe09b 100644
--- a/src/UmbracoExamine/DataServices/UmbracoContentService.cs
+++ b/src/UmbracoExamine/DataServices/UmbracoContentService.cs
@@ -13,7 +13,7 @@ namespace UmbracoExamine.DataServices
{
public class UmbracoContentService : IContentService
{
- private readonly ApplicationContext _applicationContext;
+ protected ApplicationContext ApplicationContext { get; private set; }
public UmbracoContentService()
: this(ApplicationContext.Current)
@@ -21,7 +21,7 @@ namespace UmbracoExamine.DataServices
public UmbracoContentService(ApplicationContext applicationContext)
{
- _applicationContext = applicationContext;
+ ApplicationContext = applicationContext;
}
///
@@ -60,11 +60,11 @@ namespace UmbracoExamine.DataServices
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
var xmlContent = XDocument.Parse("");
- var rootContent = _applicationContext.Services.ContentService.GetRootContent();
+ var rootContent = ApplicationContext.Services.ContentService.GetRootContent();
foreach (var c in rootContent)
{
// not sure this uses the database, but better be save
- xmlContent.Root.Add(c.ToDeepXml(_applicationContext.Services.PackagingService));
+ xmlContent.Root.Add(c.ToDeepXml(ApplicationContext.Services.PackagingService));
}
var result = ((IEnumerable)xmlContent.XPathEvaluate(xpath)).Cast();
scope.Complete();
@@ -82,7 +82,7 @@ namespace UmbracoExamine.DataServices
{
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
- var ret = _applicationContext.Services.PublicAccessService.IsProtected(path.EnsureEndsWith("," + nodeId));
+ var ret = ApplicationContext.Services.PublicAccessService.IsProtected(path.EnsureEndsWith("," + nodeId));
scope.Complete();
return ret;
}
@@ -93,14 +93,26 @@ namespace UmbracoExamine.DataServices
///
///
- public IEnumerable GetAllUserPropertyNames()
+ public virtual IEnumerable GetAllUserPropertyNames()
{
using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
{
try
- {
- var result = _applicationContext.DatabaseContext.Database.Fetch("select distinct alias from cmsPropertyType order by alias");
- scope.Complete();
+ {
+ //only return the property type aliases for media and content
+
+ var result = ApplicationContext.DatabaseContext.Database.Fetch(
+ @"select distinct cmsPropertyType.alias from cmsPropertyType
+ inner join cmsContentType on cmsContentType.nodeId = cmsPropertyType.contentTypeId
+ inner join umbracoNode on umbracoNode.id = cmsContentType.nodeId
+ where umbracoNode.nodeObjectType = @contentNodeObjectType OR umbracoNode.nodeObjectType = @mediaNodeObjectType
+ order by alias", new
+ {
+ contentNodeObjectType = Constants.ObjectTypes.DocumentType,
+ mediaNodeObjectType = Constants.ObjectTypes.MediaType
+ });
+
+ scope.Complete();
return result;
}
catch (Exception ex)
diff --git a/src/UmbracoExamine/DataServices/UmbracoMemberContentService.cs b/src/UmbracoExamine/DataServices/UmbracoMemberContentService.cs
new file mode 100644
index 0000000000..2112e686a6
--- /dev/null
+++ b/src/UmbracoExamine/DataServices/UmbracoMemberContentService.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Umbraco.Core;
+using Umbraco.Core.Logging;
+
+namespace UmbracoExamine.DataServices
+{
+ public class UmbracoMemberContentService : UmbracoContentService
+ {
+ public override IEnumerable GetAllUserPropertyNames()
+ {
+ using (var scope = ApplicationContext.Current.ScopeProvider.CreateScope())
+ {
+ try
+ {
+ //only return the property type aliases for members
+
+ var result = ApplicationContext.DatabaseContext.Database.Fetch(
+ @"select distinct cmsPropertyType.alias from cmsPropertyType
+ inner join cmsContentType on cmsContentType.nodeId = cmsPropertyType.contentTypeId
+ inner join umbracoNode on umbracoNode.id = cmsContentType.nodeId
+ where umbracoNode.nodeObjectType = @nodeObjectType
+ order by alias", new {nodeObjectType = Constants.ObjectTypes.MemberType});
+
+ scope.Complete();
+ return result;
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Error("EXCEPTION OCCURRED reading GetAllUserPropertyNames", ex);
+ return Enumerable.Empty();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/UmbracoExamine/DataServices/UmbracoMemberDataService.cs b/src/UmbracoExamine/DataServices/UmbracoMemberDataService.cs
new file mode 100644
index 0000000000..44aa2815fa
--- /dev/null
+++ b/src/UmbracoExamine/DataServices/UmbracoMemberDataService.cs
@@ -0,0 +1,10 @@
+namespace UmbracoExamine.DataServices
+{
+ public class UmbracoMemberDataService : UmbracoDataService
+ {
+ public UmbracoMemberDataService()
+ {
+ ContentService = new UmbracoMemberContentService();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/UmbracoExamine/UmbracoExamine.csproj b/src/UmbracoExamine/UmbracoExamine.csproj
index 3860dbeae6..015fc923cb 100644
--- a/src/UmbracoExamine/UmbracoExamine.csproj
+++ b/src/UmbracoExamine/UmbracoExamine.csproj
@@ -119,6 +119,8 @@
+
+
diff --git a/src/UmbracoExamine/UmbracoMemberIndexer.cs b/src/UmbracoExamine/UmbracoMemberIndexer.cs
index 1a3c9befd2..38e2f20db5 100644
--- a/src/UmbracoExamine/UmbracoMemberIndexer.cs
+++ b/src/UmbracoExamine/UmbracoMemberIndexer.cs
@@ -19,6 +19,8 @@ using Lucene.Net.Analysis;
namespace UmbracoExamine
{
+
+
///
/// Custom indexer for members
///
@@ -101,6 +103,11 @@ namespace UmbracoExamine
_memberTypeService = memberTypeService;
}
+ protected override IDataService CreateDefaultUmbracoDataService()
+ {
+ return new UmbracoMemberDataService();
+ }
+
///
/// Ensures that the'_searchEmail' is added to the user fields so that it is indexed - without having to modify the config
///