Merge branch 'v7/dev' into v8/dev

This commit is contained in:
Sebastiaan Janssen
2019-07-02 21:57:09 +02:00
4 changed files with 17 additions and 129 deletions

View File

@@ -1,94 +0,0 @@
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Web.Models;
using Umbraco.Web.WebApi;
namespace Umbraco.Web.Controllers
{
/// <summary>
/// A public web service for querying tags
/// </summary>
/// <remarks>
/// This controller does not contain methods to query for content, media or members based on tags, those methods would require
/// authentication and should not be exposed publicly.
/// </remarks>
// TODO: This controller should be moved to a more suitable place.
public class TagsController : UmbracoApiController
{
public TagsController()
{
}
public TagsController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
{
}
/// <summary>
/// Get every tag stored in the database (with optional group)
/// </summary>
public IEnumerable<TagModel> GetAllTags(string group = null)
{
return Umbraco.TagQuery.GetAllTags(group);
}
/// <summary>
/// Get all tags for content items (with optional group)
/// </summary>
/// <param name="group"></param>
/// <returns></returns>
public IEnumerable<TagModel> GetAllContentTags(string group = null)
{
return Umbraco.TagQuery.GetAllContentTags(group);
}
/// <summary>
/// Get all tags for media items (with optional group)
/// </summary>
/// <param name="group"></param>
/// <returns></returns>
public IEnumerable<TagModel> GetAllMediaTags(string group = null)
{
return Umbraco.TagQuery.GetAllMediaTags(group);
}
/// <summary>
/// Get all tags for member items (with optional group)
/// </summary>
/// <param name="group"></param>
/// <returns></returns>
public IEnumerable<TagModel> GetAllMemberTags(string group = null)
{
return Umbraco.TagQuery.GetAllMemberTags(group);
}
/// <summary>
/// Returns all tags attached to a property by entity id
/// </summary>
/// <param name="contentId"></param>
/// <param name="propertyTypeAlias"></param>
/// <param name="tagGroup"></param>
/// <returns></returns>
public IEnumerable<TagModel> GetTagsForProperty(int contentId, string propertyTypeAlias, string tagGroup = null)
{
return Umbraco.TagQuery.GetTagsForProperty(contentId, propertyTypeAlias, tagGroup);
}
/// <summary>
/// Returns all tags attached to an entity (content, media or member) by entity id
/// </summary>
/// <param name="contentId"></param>
/// <param name="tagGroup"></param>
/// <returns></returns>
public IEnumerable<TagModel> GetTagsForEntity(int contentId, string tagGroup = null)
{
return Umbraco.TagQuery.GetTagsForEntity(contentId, tagGroup);
}
}
}

View File

@@ -238,10 +238,6 @@ namespace Umbraco.Web.Editors
"updateCheckApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<UpdateCheckController>(
controller => controller.GetCheck())
},
{
"tagApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<TagsController>(
controller => controller.GetAllTags(null))
},
{
"templateApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<TemplateController>(
controller => controller.GetById(0))

View File

@@ -422,16 +422,7 @@ namespace Umbraco.Web.Editors
{
//TODO: Need to check for Object types that support hierarchy here, some might not.
int[] startNodes = null;
switch (type)
{
case UmbracoEntityTypes.Document:
startNodes = Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService);
break;
case UmbracoEntityTypes.Media:
startNodes = Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService);
break;
}
var startNodes = GetStartNodes(type);
var ignoreUserStartNodes = IsDataTypeIgnoringUserStartNodes(dataTypeId);
@@ -556,16 +547,7 @@ namespace Umbraco.Web.Editors
IEnumerable<IEntitySlim> entities;
long totalRecords;
int[] startNodes = null;
switch (type)
{
case UmbracoEntityTypes.Document:
startNodes = Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService);
break;
case UmbracoEntityTypes.Media:
startNodes = Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService);
break;
}
var startNodes = GetStartNodes(type);
var ignoreUserStartNodes = IsDataTypeIgnoringUserStartNodes(dataTypeId);
@@ -630,6 +612,20 @@ namespace Umbraco.Web.Editors
}
}
private int[] GetStartNodes(UmbracoEntityTypes type)
{
switch (type)
{
case UmbracoEntityTypes.Document:
return Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService);
case UmbracoEntityTypes.Media:
return Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService);
default:
return new int[0];
}
}
public PagedResult<EntityBasic> GetPagedDescendants(
int id,
@@ -656,16 +652,7 @@ namespace Umbraco.Web.Editors
{
// root is special: we reduce it to start nodes
int[] aids = null;
switch (type)
{
case UmbracoEntityTypes.Document:
aids = Security.CurrentUser.CalculateContentStartNodeIds(Services.EntityService);
break;
case UmbracoEntityTypes.Media:
aids = Security.CurrentUser.CalculateMediaStartNodeIds(Services.EntityService);
break;
}
int[] aids = GetStartNodes(type);
var ignoreUserStartNodes = IsDataTypeIgnoringUserStartNodes(dataTypeId);
entities = aids == null || aids.Contains(Constants.System.Root) || ignoreUserStartNodes

View File

@@ -1172,7 +1172,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>Reference.map</DependentUpon>
</Compile>
<Compile Include="Controllers\TagsController.cs" />
<Compile Include="UmbracoAuthorizedHttpHandler.cs" />
<Compile Include="UmbracoHttpHandler.cs" />
<Compile Include="UmbracoWebService.cs">