manual merging/fixing, project builds now, but need to manually merge the remaining

This commit is contained in:
Shannon
2019-06-28 13:24:13 +10:00
parent 84aa861a5b
commit 568835f7e2
12 changed files with 123 additions and 46 deletions

View File

@@ -6,6 +6,10 @@ namespace Umbraco.Core
{
public static class DataTypes
{
//NOTE: unfortunately due to backwards compat we can't move/rename these, with the addition of the GUID
//constants, it would make more sense to have these suffixed with "ID" or in a Subclass called "INT", for
//now all we can do is make a subclass called Guids to put the GUID IDs.
public const int LabelString = -92;
public const int LabelInt = -91;
public const int LabelBigint = -93;
@@ -25,16 +29,16 @@ namespace Umbraco.Core
public const int Tags = 1041;
public static class ReservedPreValueKeys
{
public const string IgnoreUserStartNodes = "ignoreUserStartNodes";
}
/// <summary>
/// Defines the identifiers for Umbraco data types as constants for easy centralized access/management.
/// </summary>
internal static class BuiltInDataTypes
{
public static class ReservedPreValueKeys
{
public const string IgnoreUserStartNodes = "ignoreUserStartNodes";
}
public static class Guids
{
/// <summary>
/// Guid for Content Picker as string

View File

@@ -38,31 +38,31 @@ namespace Umbraco.Core.Models
private static readonly ISet<Guid> IdsOfBuildInDataTypes = new HashSet<Guid>()
{
Constants.DataTypes.ContentPickerGuid,
Constants.DataTypes.MemberPickerGuid,
Constants.DataTypes.MediaPickerGuid,
Constants.DataTypes.MultipleMediaPickerGuid,
Constants.DataTypes.RelatedLinksGuid,
Constants.DataTypes.MemberGuid,
Constants.DataTypes.ImageCropperGuid,
Constants.DataTypes.TagsGuid,
Constants.DataTypes.ListViewContentGuid,
Constants.DataTypes.ListViewMediaGuid,
Constants.DataTypes.ListViewMembersGuid,
Constants.DataTypes.DatePickerWithTimeGuid,
Constants.DataTypes.ApprovedColorGuid,
Constants.DataTypes.DropdownMultipleGuid,
Constants.DataTypes.RadioboxGuid,
Constants.DataTypes.DatePickerGuid,
Constants.DataTypes.DropdownGuid,
Constants.DataTypes.CheckboxListGuid,
Constants.DataTypes.CheckboxGuid,
Constants.DataTypes.NumericGuid,
Constants.DataTypes.RichtextEditorGuid,
Constants.DataTypes.TextstringGuid,
Constants.DataTypes.TextareaGuid,
Constants.DataTypes.UploadGuid,
Constants.DataTypes.LabelGuid,
Constants.DataTypes.Guids.ContentPickerGuid,
Constants.DataTypes.Guids.MemberPickerGuid,
Constants.DataTypes.Guids.MediaPickerGuid,
Constants.DataTypes.Guids.MultipleMediaPickerGuid,
Constants.DataTypes.Guids.RelatedLinksGuid,
Constants.DataTypes.Guids.MemberGuid,
Constants.DataTypes.Guids.ImageCropperGuid,
Constants.DataTypes.Guids.TagsGuid,
Constants.DataTypes.Guids.ListViewContentGuid,
Constants.DataTypes.Guids.ListViewMediaGuid,
Constants.DataTypes.Guids.ListViewMembersGuid,
Constants.DataTypes.Guids.DatePickerWithTimeGuid,
Constants.DataTypes.Guids.ApprovedColorGuid,
Constants.DataTypes.Guids.DropdownMultipleGuid,
Constants.DataTypes.Guids.RadioboxGuid,
Constants.DataTypes.Guids.DatePickerGuid,
Constants.DataTypes.Guids.DropdownGuid,
Constants.DataTypes.Guids.CheckboxListGuid,
Constants.DataTypes.Guids.CheckboxGuid,
Constants.DataTypes.Guids.NumericGuid,
Constants.DataTypes.Guids.RichtextEditorGuid,
Constants.DataTypes.Guids.TextstringGuid,
Constants.DataTypes.Guids.TextareaGuid,
Constants.DataTypes.Guids.UploadGuid,
Constants.DataTypes.Guids.LabelGuid,
};
/// <summary>
@@ -70,7 +70,7 @@ namespace Umbraco.Core.Models
/// </summary>
/// <param name="dataType">The data type definition.</param>
/// <returns></returns>
internal static bool IsBuildInDataType(this IDataTypeDefinition dataType)
internal static bool IsBuildInDataType(this IDataType dataType)
{
return IsBuildInDataType(dataType.Key);
}

View File

@@ -527,7 +527,7 @@ namespace Umbraco.Core.Services
#endregion
IEnumerable<string> GetAnchorValuesFromRTEs(int id);
IEnumerable<string> GetAnchorValuesFromRTEContent(string rteContent);
IEnumerable<string> GetAnchorValuesFromRTEs(int id, string culture = "*");
IEnumerable<string> GetAnchorValuesFromRTEContent(string rteContent, string culture = "*");
}
}

View File

@@ -4,6 +4,7 @@ using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
/// <summary>
/// Defines the DataType Service, which is an easy access to operations involving <see cref="IDataType"/>
/// </summary>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using Umbraco.Core.Events;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
@@ -31,6 +32,7 @@ namespace Umbraco.Core.Services.Implement
private IQuery<IContent> _queryNotTrashed;
//TODO: The non-lazy object should be injected
private readonly Lazy<PropertyValidationService> _propertyValidationService = new Lazy<PropertyValidationService>(() => new PropertyValidationService());
private static readonly Regex AnchorRegex = new Regex("<a id=\"(.*?)\">", RegexOptions.Compiled);
#region Constructors
@@ -3024,5 +3026,38 @@ namespace Umbraco.Core.Services.Implement
}
#endregion
#region RTE Anchor values
public IEnumerable<string> GetAnchorValuesFromRTEs(int id, string culture = "*")
{
var result = new List<string>();
var content = GetById(id);
foreach (var contentProperty in content.Properties)
{
if (contentProperty.PropertyType.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.TinyMce))
{
var value = contentProperty.GetValue(culture)?.ToString();
if (!string.IsNullOrEmpty(value))
{
result.AddRange(GetAnchorValuesFromRTEContent(value));
}
}
}
return result;
}
public IEnumerable<string> GetAnchorValuesFromRTEContent(string rteContent, string culture = "*")
{
var result = new List<string>();
var matches = AnchorRegex.Matches(rteContent);
foreach (Match match in matches)
{
result.Add(match.Value.Split('\"')[1]);
}
return result;
}
#endregion
}
}

View File

@@ -255,6 +255,7 @@
<Compile Include="Models\PublishedContent\ILivePublishedModelFactory.cs" />
<Compile Include="Models\PublishedContent\IPublishedContentType.cs" />
<Compile Include="Models\PublishedContent\IPublishedPropertyType.cs" />
<Compile Include="PropertyEditors\IIgnoreUserStartNodesConfig.cs" />
<Compile Include="PublishedContentExtensions.cs" />
<Compile Include="Models\PublishedContent\UrlMode.cs" />
<Compile Include="Persistence\Dtos\PropertyTypeCommonDto.cs" />
@@ -264,6 +265,7 @@
<Compile Include="PropertyEditors\DateTimeConfiguration.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\RenameLabelAndRichTextPropertyEditorAliases.cs" />
<Compile Include="PublishedModelFactoryExtensions.cs" />
<Compile Include="Services\DateTypeServiceExtensions.cs" />
<Compile Include="Services\PropertyValidationService.cs" />
<Compile Include="Composing\TypeCollectionBuilderBase.cs" />
<Compile Include="TypeLoaderExtensions.cs" />

View File

@@ -287,10 +287,11 @@ namespace Umbraco.Web.Editors
}
//fixme - culture?
[HttpGet]
public UrlAndAnchors GetUrlAndAnchors([FromUri]int id)
{
var url = Umbraco.Url(id);
var url = UmbracoContext.UrlProvider.GetUrl(id);
var anchorValues = Services.ContentService.GetAnchorValuesFromRTEs(id);
return new UrlAndAnchors(url, anchorValues);
}
@@ -300,6 +301,7 @@ namespace Umbraco.Web.Editors
public string RteContent { get; set; }
}
//fixme - culture?
[HttpGet]
[HttpPost]
public IEnumerable<string> GetAnchors(AnchorsModel model)
@@ -567,7 +569,7 @@ namespace Umbraco.Web.Editors
var objectType = ConvertToObjectType(type);
if (objectType.HasValue)
{
IEnumerable<IUmbracoEntity> entities;
IEnumerable<IEntitySlim> entities;
long totalRecords;
int[] startNodes = null;
@@ -600,8 +602,7 @@ namespace Umbraco.Web.Editors
}
// else proceed as usual
//entities = Services.EntityService.GetPagedChildren(id, objectType.Value, pageNumber - 1, pageSize, out totalRecords, orderBy, orderDirection, filter);
entities = Services.EntityService.GetPagedChildren(id, objectType.Value, pageNumber - 1, pageSize, out var totalRecords,
entities = Services.EntityService.GetPagedChildren(id, objectType.Value, pageNumber - 1, pageSize, out totalRecords,
filter.IsNullOrWhiteSpace()
? null
: SqlContext.Query<IUmbracoEntity>().Where(x => x.Name.Contains(filter)),
@@ -776,7 +777,7 @@ namespace Umbraco.Web.Editors
var ids = Services.EntityService.Get(id).Path.Split(',').Select(int.Parse).Distinct().ToArray();
var ignoreUserStartNodes = IsDataTypeIgnoringUserStartNodes(dataTypeId);
var ignoreUserStartNodes = IsDataTypeIgnoringUserStartNodes(queryStrings?.GetValue<Guid?>("dataTypeId"));
if (ignoreUserStartNodes == false)
{
int[] aids = null;

View File

@@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Umbraco.Web.Models.ContentEditing
{
[DataContract(Name = "urlAndAnchors", Namespace = "")]
public class UrlAndAnchors
{
public UrlAndAnchors(string url, IEnumerable<string> anchorValues)
{
Url = url;
AnchorValues = anchorValues;
}
[DataMember(Name = "url")]
public string Url { get; }
[DataMember(Name = "anchorValues")]
public IEnumerable<string> AnchorValues { get; }
}
}

View File

@@ -2,12 +2,18 @@ using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
public class MultiUrlPickerConfiguration
public class MultiUrlPickerConfiguration : IIgnoreUserStartNodesConfig
{
[ConfigurationField("minNumber", "Minimum number of items", "number")]
public int MinNumber { get; set; }
[ConfigurationField("maxNumber", "Maximum number of items", "number")]
public int MaxNumber { get; set; }
[ConfigurationField(Core.Constants.DataTypes.ReservedPreValueKeys.IgnoreUserStartNodes, "Selecting this option allows a user to choose nodes that they normally don't have access to.", "boolean")]
public bool IgnoreUserStartNodes { get; set; }
}
}

View File

@@ -55,7 +55,7 @@ namespace Umbraco.Web.Search
string query,
UmbracoEntityTypes entityType,
int pageSize,
long pageIndex, out long totalFound, string searchFrom = null)
long pageIndex, out long totalFound, string searchFrom = null, bool ignoreUserStartNodes = false)
{
var sb = new StringBuilder();

View File

@@ -17,7 +17,7 @@ using Umbraco.Core.Models.Entities;
using System.Web.Http.ModelBinding;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing;
using Umbraco.Core.Security;
namespace Umbraco.Web.Trees
{
@@ -90,12 +90,18 @@ namespace Umbraco.Web.Trees
internal TreeNode GetSingleTreeNodeWithAccessCheck(IEntitySlim e, string parentId, FormDataCollection queryStrings,
int[] startNodeIds, string[] startNodePaths, bool ignoreUserStartNodes)
{
var entityIsAncestorOfStartNodes = Security.CurrentUser.IsInBranchOfStartNode(e, Services.EntityService, RecycleBinId, out var hasPathAccess);
if (entityIsAncestorOfStartNodes == false)
var entityIsAncestorOfStartNodes = ContentPermissionsHelper.IsInBranchOfStartNode(e.Path, startNodeIds, startNodePaths, out var hasPathAccess);
if (ignoreUserStartNodes == false && entityIsAncestorOfStartNodes == false)
return null;
var treeNode = GetSingleTreeNode(e, parentId, queryStrings);
if (hasPathAccess == false)
if (treeNode == null)
{
//this means that the user has NO access to this node via permissions! They at least need to have browse permissions to see
//the node so we need to return null;
return null;
}
if (ignoreUserStartNodes == false && hasPathAccess == false)
{
treeNode.AdditionalData["noAccess"] = true;
}

View File

@@ -206,6 +206,7 @@
<Compile Include="Models\ContentEditing\LinkDisplay.cs" />
<Compile Include="Models\ContentEditing\MacroDisplay.cs" />
<Compile Include="Models\ContentEditing\MacroParameterDisplay.cs" />
<Compile Include="Models\ContentEditing\UrlAndAnchors.cs" />
<Compile Include="Models\Mapping\CommonMapper.cs" />
<Compile Include="Models\Mapping\MapperContextExtensions.cs" />
<Compile Include="Models\PublishedContent\HybridVariationContextAccessor.cs" />