From bc2eb5a7841c8f278d99660dc9b97ea3b4caaf48 Mon Sep 17 00:00:00 2001 From: Zeegaan Date: Mon, 20 Jun 2022 14:12:33 +0200 Subject: [PATCH] Fix up after merge --- src/Umbraco.Core/Models/CultureImpact.cs | 127 ++++-------------- .../Models/Membership/IUserGroup.cs | 6 - .../Models/Membership/UserGroup.cs | 6 - .../Repositories/Implement/UserRepository.cs | 29 ++-- .../Controllers/ContentController.cs | 5 - 5 files changed, 40 insertions(+), 133 deletions(-) diff --git a/src/Umbraco.Core/Models/CultureImpact.cs b/src/Umbraco.Core/Models/CultureImpact.cs index cf7d5a99d8..f93074e045 100644 --- a/src/Umbraco.Core/Models/CultureImpact.cs +++ b/src/Umbraco.Core/Models/CultureImpact.cs @@ -18,24 +18,24 @@ public sealed class CultureImpact /// /// The culture code. /// A value indicating whether the culture is the default culture. - /// A value indicating if publishing invariant properties from non-default language. - internal CultureImpact(string? culture, bool isDefault = false, bool allowEditInvariantFromNonDefault = false) + /// A value indicating if publishing invariant properties from non-default language. + internal CultureImpact(string? culture, bool isDefault = false, bool allowEditInvariantFromNonDefault = false) { if (culture != null && culture.IsNullOrWhiteSpace()) - { + { throw new ArgumentException("Culture \"\" is not valid here."); - } + } Culture = culture; if ((culture == null || culture == "*") && isDefault) - { + { throw new ArgumentException("The invariant or 'all' culture can not be the default culture."); - } + } ImpactsOnlyDefaultCulture = isDefault; - AllowEditInvariantFromNonDefault = allowEditInvariantFromNonDefault; + AllowEditInvariantFromNonDefault = allowEditInvariantFromNonDefault; } [Flags] @@ -145,7 +145,8 @@ public sealed class CultureImpact /// /// /// - public static string? GetCultureForInvariantErrors(IContent? content, string?[] savingCultures, string? defaultCulture) + public static string? GetCultureForInvariantErrors(IContent? content, string?[] savingCultures, + string? defaultCulture) { if (content == null) { @@ -181,24 +182,24 @@ public sealed class CultureImpact /// /// The culture code. /// A value indicating whether the culture is the default culture. - /// A value indicating if publishing invariant properties from non-default language. - [Obsolete("Use ICultureImpactService instead.")] + /// A value indicating if publishing invariant properties from non-default language. + [Obsolete("Use ICultureImpactService instead.")] public static CultureImpact Explicit(string? culture, bool isDefault) { if (culture == null) - { + { throw new ArgumentException("Culture is not explicit."); - } + } if (culture.IsNullOrWhiteSpace()) - { + { throw new ArgumentException("Culture \"\" is not explicit."); - } + } if (culture == "*") - { + { throw new ArgumentException("Culture \"*\" is not explicit."); - } + } return new CultureImpact(culture, isDefault); } @@ -210,11 +211,11 @@ public sealed class CultureImpact /// The culture code. /// A value indicating whether the culture is the default culture. /// The content item. - /// A value indicating if publishing invariant properties from non-default language. + /// A value indicating if publishing invariant properties from non-default language. /// /// Validates that the culture is compatible with the variation. /// - [Obsolete("Use ICultureImpactService instead, scheduled for removal in V12")] + [Obsolete("Use ICultureImpactService instead, scheduled for removal in V12")] public static CultureImpact? Create(string culture, bool isDefault, IContent content) { // throws if not successful @@ -230,14 +231,15 @@ public sealed class CultureImpact /// A value indicating whether the culture is the default culture. /// A content variation. /// A value indicating whether to throw if the impact cannot be created. - /// A value indicating if publishing invariant properties from non-default language. + /// A value indicating if publishing invariant properties from non-default language. /// The impact if it could be created, otherwise null. /// A value indicating whether the impact could be created. /// /// Validates that the culture is compatible with the variation. /// - // TODO: Remove this once Create() can be removed (V12), this already lives in CultureImpactService - internal static bool TryCreate(string culture, bool isDefault, ContentVariation variation, bool throwOnFail, bool editInvariantFromNonDefault, out CultureImpact? impact) + // TODO: Remove this once Create() can be removed (V12), this already lives in CultureImpactService + internal static bool TryCreate(string culture, bool isDefault, ContentVariation variation, bool throwOnFail, + bool editInvariantFromNonDefault, out CultureImpact? impact) { impact = null; @@ -314,89 +316,10 @@ public sealed class CultureImpact } // return specific impact - impact = new CultureImpact(culture, isDefault, editInvariantFromNonDefault); + impact = new CultureImpact(culture, isDefault, editInvariantFromNonDefault); return true; } - /// - /// Gets the culture code. - /// - /// - /// Can be null (invariant) or * (all cultures) or a specific culture code. - /// - public string? Culture { get; } - public bool AllowEditInvariantFromNonDefault { get; } - - /// - /// Gets a value indicating whether this impact impacts all cultures, including, - /// indirectly, the invariant culture. - /// - public bool ImpactsAllCultures => Culture == "*"; - - /// - /// Gets a value indicating whether this impact impacts only the invariant culture, - /// directly, not because all cultures are impacted. - /// - public bool ImpactsOnlyInvariantCulture => Culture == null; - - /// - /// Gets a value indicating whether this impact impacts an implicit culture. - /// - /// And then it does not impact the invariant culture. The impacted - /// explicit culture could be the default culture. - public bool ImpactsExplicitCulture => Culture != null && Culture != "*"; - - /// - /// Gets a value indicating whether this impact impacts the default culture, directly, - /// not because all cultures are impacted. - /// - public bool ImpactsOnlyDefaultCulture {get; } - - /// - /// Gets a value indicating whether this impact impacts the invariant properties, either - /// directly, or because all cultures are impacted, or because the default culture is impacted. - /// - public bool ImpactsInvariantProperties => Culture == null || Culture == "*" || ImpactsOnlyDefaultCulture; - - /// - /// Gets a value indicating whether this also impact impacts the invariant properties, - /// even though it does not impact the invariant culture, neither directly (ImpactsInvariantCulture) - /// nor indirectly (ImpactsAllCultures). - /// - public bool ImpactsAlsoInvariantProperties => !ImpactsOnlyInvariantCulture && - !ImpactsAllCultures && - (ImpactsOnlyDefaultCulture || AllowEditInvariantFromNonDefault); - - public Behavior CultureBehavior - { - get - { - //null can only be invariant - if (Culture == null) return Behavior.InvariantCulture | Behavior.InvariantProperties; - - // * is All which means its also invariant properties since this will include the default language - if (Culture == "*") return (Behavior.AllCultures | Behavior.InvariantProperties); - - //else it's explicit - var result = Behavior.ExplicitCulture; - - //if the explicit culture is the default, then the behavior is also InvariantProperties - if (ImpactsOnlyDefaultCulture) - result |= Behavior.InvariantProperties; - - return result; - } - } - - - [Flags] - public enum Behavior : byte - { - AllCultures = 1, - InvariantCulture = 2, - ExplicitCulture = 4, - InvariantProperties = 8 - } - } + public bool AllowEditInvariantFromNonDefault { get; } } diff --git a/src/Umbraco.Core/Models/Membership/IUserGroup.cs b/src/Umbraco.Core/Models/Membership/IUserGroup.cs index 58330a3477..d698a98ccf 100644 --- a/src/Umbraco.Core/Models/Membership/IUserGroup.cs +++ b/src/Umbraco.Core/Models/Membership/IUserGroup.cs @@ -49,10 +49,4 @@ public interface IUserGroup : IEntity, IRememberBeingDirty /// Specifies the number of users assigned to this group /// int UserCount { get; } - - void RemoveAllowedSection(string sectionAlias); - - void AddAllowedSection(string sectionAlias); - - void ClearAllowedSections(); } diff --git a/src/Umbraco.Core/Models/Membership/UserGroup.cs b/src/Umbraco.Core/Models/Membership/UserGroup.cs index 755374b250..c470629a01 100644 --- a/src/Umbraco.Core/Models/Membership/UserGroup.cs +++ b/src/Umbraco.Core/Models/Membership/UserGroup.cs @@ -28,12 +28,6 @@ public class UserGroup : EntityBase, IUserGroup, IReadOnlyUserGroup private int? _startContentId; private int? _startMediaId; - //Custom comparer for enumerable - private static readonly DelegateEqualityComparer> StringEnumerableComparer = - new DelegateEqualityComparer>( - (enum1, enum2) => enum1.UnsortedSequenceEqual(enum2), - enum1 => enum1.GetHashCode()); - /// /// Constructor to create a new user group /// diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs index 36e7916fd9..5bfb6c0bda 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs @@ -406,16 +406,16 @@ SELECT 4 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0 List? startNodes = Database.Fetch(sql); - // get groups2languages + // get groups2languages - sql = SqlContext.Sql() - .Select() - .From() - .WhereIn(x => x.UserGroupId, groupIds); + sql = SqlContext.Sql() + .Select() + .From() + .WhereIn(x => x.UserGroupId, groupIds); - var groups2languages = Database.Fetch(sql) - .GroupBy(x => x.UserGroupId) - .ToDictionary(x => x.Key, x => x); + var groups2languages = Database.Fetch(sql) + .GroupBy(x => x.UserGroupId) + .ToDictionary(x => x.Key, x => x); // map groups @@ -445,14 +445,15 @@ SELECT 4 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0 group.UserGroup2AppDtos = list.ToList(); // groups2apps is distinct } - // map languages + } - foreach (var group in groups.Values) + // map languages + + foreach (var group in groups.Values) + { + if (groups2languages.TryGetValue(group.Id, out var list)) { - if (groups2languages.TryGetValue(group.Id, out var list)) - { - group.UserGroup2LanguageDtos = list.ToList(); // groups2apps is distinct - } + group.UserGroup2LanguageDtos = list.ToList(); // groups2apps is distinct } } } diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs index c2024b3beb..851b65ef1c 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs @@ -57,12 +57,7 @@ public class ContentController : ContentControllerBase private readonly ILocalizationService _localizationService; private readonly ILocalizedTextService _localizedTextService; private readonly INotificationService _notificationService; - private readonly ActionCollection _actionCollection; - private readonly ISqlContext _sqlContext; - private readonly IAuthorizationService _authorizationService; - private readonly IContentVersionService _contentVersionService; private readonly ICultureImpactService _cultureImpactService; - private readonly Lazy> _allLangs; private readonly ILogger _logger; private readonly PropertyEditorCollection _propertyEditors; private readonly IPublishedUrlProvider _publishedUrlProvider;