Merge remote-tracking branch 'origin/v10/dev' into v11/dev
This commit is contained in:
@@ -134,27 +134,6 @@ public static class PublishedElementExtensions
|
||||
|
||||
#endregion
|
||||
|
||||
#region CheckVariation
|
||||
/// <summary>
|
||||
/// Method to check if VariationContext culture differs from culture parameter, if so it will update the VariationContext for the PublishedValueFallback.
|
||||
/// </summary>
|
||||
/// <param name="publishedValueFallback">The requested PublishedValueFallback.</param>
|
||||
/// <param name="culture">The requested culture.</param>
|
||||
/// <param name="segment">The requested segment.</param>
|
||||
/// <returns></returns>
|
||||
private static void EventuallyUpdateVariationContext(IPublishedValueFallback publishedValueFallback, string? culture, string? segment)
|
||||
{
|
||||
IVariationContextAccessor? variationContextAccessor = publishedValueFallback.VariationContextAccessor;
|
||||
|
||||
//If there is a difference in requested culture and the culture that is set in the VariationContext, it will pick wrong localized content.
|
||||
//This happens for example using links to localized content in a RichText Editor.
|
||||
if (!string.IsNullOrEmpty(culture) && variationContextAccessor?.VariationContext?.Culture != culture)
|
||||
{
|
||||
variationContextAccessor!.VariationContext = new VariationContext(culture, segment);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Value<T>
|
||||
|
||||
/// <summary>
|
||||
@@ -195,8 +174,6 @@ public static class PublishedElementExtensions
|
||||
{
|
||||
IPublishedProperty? property = content.GetProperty(alias);
|
||||
|
||||
EventuallyUpdateVariationContext(publishedValueFallback, culture, segment);
|
||||
|
||||
// if we have a property, and it has a value, return that value
|
||||
if (property != null && property.HasValue(culture, segment))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Umbraco.Cms.Core.Models.PublishedContent;
|
||||
/// </summary>
|
||||
public interface IPublishedValueFallback
|
||||
{
|
||||
[Obsolete("Scheduled for removal in v14")]
|
||||
/// <summary>
|
||||
/// VariationContextAccessor that is not required to be implemented, therefore throws NotImplementedException as default.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,6 +20,7 @@ public class PublishedValueFallback : IPublishedValueFallback
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
}
|
||||
|
||||
[Obsolete("Scheduled for removal in v14")]
|
||||
public IVariationContextAccessor VariationContextAccessor { get { return _variationContextAccessor; } }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -167,12 +167,7 @@ public class ContentPermissions
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
if (permissionsToCheck == null)
|
||||
{
|
||||
permissionsToCheck = Array.Empty<char>();
|
||||
}
|
||||
|
||||
bool? hasPathAccess = null;
|
||||
bool hasPathAccess;
|
||||
entity = null;
|
||||
|
||||
if (nodeId == Constants.System.Root)
|
||||
@@ -183,19 +178,17 @@ public class ContentPermissions
|
||||
{
|
||||
hasPathAccess = user.HasContentBinAccess(_entityService, _appCaches);
|
||||
}
|
||||
|
||||
if (hasPathAccess.HasValue)
|
||||
else
|
||||
{
|
||||
return hasPathAccess.Value ? ContentAccess.Granted : ContentAccess.Denied;
|
||||
}
|
||||
entity = _entityService.Get(nodeId, UmbracoObjectTypes.Document);
|
||||
|
||||
entity = _entityService.Get(nodeId, UmbracoObjectTypes.Document);
|
||||
if (entity == null)
|
||||
{
|
||||
return ContentAccess.NotFound;
|
||||
}
|
||||
if (entity == null)
|
||||
{
|
||||
return ContentAccess.NotFound;
|
||||
}
|
||||
|
||||
hasPathAccess = user.HasContentPathAccess(entity, _entityService, _appCaches);
|
||||
hasPathAccess = user.HasContentPathAccess(entity, _entityService, _appCaches);
|
||||
}
|
||||
|
||||
if (hasPathAccess == false)
|
||||
{
|
||||
@@ -208,7 +201,8 @@ public class ContentPermissions
|
||||
}
|
||||
|
||||
// get the implicit/inherited permissions for the user for this path
|
||||
return CheckPermissionsPath(entity.Path, user, permissionsToCheck)
|
||||
// if there is no entity for this id, than just use the id as the path (i.e. -1 or -20)
|
||||
return CheckPermissionsPath(entity?.Path ?? nodeId.ToString(), user, permissionsToCheck)
|
||||
? ContentAccess.Granted
|
||||
: ContentAccess.Denied;
|
||||
}
|
||||
@@ -235,12 +229,7 @@ public class ContentPermissions
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
if (permissionsToCheck == null)
|
||||
{
|
||||
permissionsToCheck = Array.Empty<char>();
|
||||
}
|
||||
|
||||
bool? hasPathAccess = null;
|
||||
bool hasPathAccess;
|
||||
contentItem = null;
|
||||
|
||||
if (nodeId == Constants.System.Root)
|
||||
@@ -251,19 +240,17 @@ public class ContentPermissions
|
||||
{
|
||||
hasPathAccess = user.HasContentBinAccess(_entityService, _appCaches);
|
||||
}
|
||||
|
||||
if (hasPathAccess.HasValue)
|
||||
else
|
||||
{
|
||||
return hasPathAccess.Value ? ContentAccess.Granted : ContentAccess.Denied;
|
||||
}
|
||||
contentItem = _contentService.GetById(nodeId);
|
||||
|
||||
contentItem = _contentService.GetById(nodeId);
|
||||
if (contentItem == null)
|
||||
{
|
||||
return ContentAccess.NotFound;
|
||||
}
|
||||
if (contentItem == null)
|
||||
{
|
||||
return ContentAccess.NotFound;
|
||||
}
|
||||
|
||||
hasPathAccess = user.HasPathAccess(contentItem, _entityService, _appCaches);
|
||||
hasPathAccess = user.HasPathAccess(contentItem, _entityService, _appCaches);
|
||||
}
|
||||
|
||||
if (hasPathAccess == false)
|
||||
{
|
||||
@@ -276,7 +263,8 @@ public class ContentPermissions
|
||||
}
|
||||
|
||||
// get the implicit/inherited permissions for the user for this path
|
||||
return CheckPermissionsPath(contentItem.Path, user, permissionsToCheck)
|
||||
// if there is no content item for this id, than just use the id as the path (i.e. -1 or -20)
|
||||
return CheckPermissionsPath(contentItem?.Path ?? nodeId.ToString(), user, permissionsToCheck)
|
||||
? ContentAccess.Granted
|
||||
: ContentAccess.Denied;
|
||||
}
|
||||
@@ -288,8 +276,7 @@ public class ContentPermissions
|
||||
permissionsToCheck = Array.Empty<char>();
|
||||
}
|
||||
|
||||
// get the implicit/inherited permissions for the user for this path,
|
||||
// if there is no content item for this id, than just use the id as the path (i.e. -1 or -20)
|
||||
// get the implicit/inherited permissions for the user for this path
|
||||
EntityPermissionSet permission = _userService.GetPermissionsForPath(user, path);
|
||||
|
||||
var allowed = true;
|
||||
|
||||
@@ -819,6 +819,7 @@ public class ContentController : ContentControllerBase
|
||||
|
||||
return pagedResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a blueprint from a content item
|
||||
/// </summary>
|
||||
@@ -1117,7 +1118,7 @@ public class ContentController : ContentControllerBase
|
||||
AddDomainWarnings(publishStatus.Content, successfulCultures, globalNotifications);
|
||||
AddPublishStatusNotifications(new[] { publishStatus }, globalNotifications, notifications, successfulCultures);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case ContentSaveAction.PublishWithDescendants:
|
||||
case ContentSaveAction.PublishWithDescendantsNew:
|
||||
{
|
||||
@@ -1134,7 +1135,7 @@ public class ContentController : ContentControllerBase
|
||||
AddDomainWarnings(publishStatus, successfulCultures, globalNotifications);
|
||||
AddPublishStatusNotifications(publishStatus, globalNotifications, notifications, successfulCultures);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case ContentSaveAction.PublishWithDescendantsForce:
|
||||
case ContentSaveAction.PublishWithDescendantsForceNew:
|
||||
{
|
||||
@@ -1150,7 +1151,7 @@ public class ContentController : ContentControllerBase
|
||||
var publishStatus = PublishBranchInternal(contentItem, true, cultureForInvariantErrors, out wasCancelled, out var successfulCultures).ToList();
|
||||
AddPublishStatusNotifications(publishStatus, globalNotifications, notifications, successfulCultures);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -2804,7 +2805,7 @@ public class ContentController : ContentControllerBase
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.SuccessPublish:
|
||||
{
|
||||
// TODO: Here we should have messaging for when there are release dates specified like https://github.com/umbraco/Umbraco-CMS/pull/3507
|
||||
@@ -2832,7 +2833,7 @@ public class ContentController : ContentControllerBase
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishPathNotPublished:
|
||||
{
|
||||
//TODO: This doesn't take into account variations with the successfulCultures param
|
||||
@@ -2841,14 +2842,14 @@ public class ContentController : ContentControllerBase
|
||||
_localizedTextService.Localize(null, "publish"),
|
||||
_localizedTextService.Localize("publish", "contentPublishedFailedByParent", new[] { names }).Trim());
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishCancelledByEvent:
|
||||
{
|
||||
//TODO: This doesn't take into account variations with the successfulCultures param
|
||||
var names = string.Join(", ", status.Select(x => $"'{x.Content?.Name}'"));
|
||||
AddCancelMessage(display, "publish", "contentPublishedFailedByEvent", new[] { names });
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishAwaitingRelease:
|
||||
{
|
||||
//TODO: This doesn't take into account variations with the successfulCultures param
|
||||
@@ -2857,7 +2858,7 @@ public class ContentController : ContentControllerBase
|
||||
_localizedTextService.Localize(null, "publish"),
|
||||
_localizedTextService.Localize("publish", "contentPublishedFailedAwaitingRelease", new[] { names }).Trim());
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishHasExpired:
|
||||
{
|
||||
//TODO: This doesn't take into account variations with the successfulCultures param
|
||||
@@ -2866,7 +2867,7 @@ public class ContentController : ContentControllerBase
|
||||
_localizedTextService.Localize(null, "publish"),
|
||||
_localizedTextService.Localize("publish", "contentPublishedFailedExpired", new[] { names }).Trim());
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishIsTrashed:
|
||||
{
|
||||
//TODO: This doesn't take into account variations with the successfulCultures param
|
||||
@@ -2875,7 +2876,7 @@ public class ContentController : ContentControllerBase
|
||||
_localizedTextService.Localize(null, "publish"),
|
||||
_localizedTextService.Localize("publish", "contentPublishedFailedIsTrashed", new[] { names }).Trim());
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishContentInvalid:
|
||||
{
|
||||
if (successfulCultures == null)
|
||||
@@ -2899,7 +2900,7 @@ public class ContentController : ContentControllerBase
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PublishResultType.FailedPublishMandatoryCultureMissing:
|
||||
display.AddWarningNotification(
|
||||
_localizedTextService.Localize(null, "publish"),
|
||||
|
||||
@@ -79,7 +79,6 @@ public abstract class ContentControllerBase : BackOfficeNotificationsController
|
||||
ModelState.AddModelError("id", $"content with id: {id} was not found");
|
||||
NotFoundObjectResult errorResponse = NotFound(ModelState);
|
||||
|
||||
|
||||
return errorResponse;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +278,7 @@ internal sealed class ContentSaveValidationAttribute : TypeFilterAttribute
|
||||
|
||||
if (!authorizationResult.Succeeded)
|
||||
{
|
||||
actionContext.Result = new ForbidResult();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user