From d2933cab7355b9a77ec802e4bc1efae9a3bf9743 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 10 Jun 2013 13:46:11 -0400 Subject: fixed ratings. moved them to static text files --- MediaBrowser.Controller/Entities/BaseItem.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 64d3810fae..974b3f864e 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -143,6 +143,7 @@ namespace MediaBrowser.Controller.Entities public static ILibraryManager LibraryManager { get; set; } public static IServerConfigurationManager ConfigurationManager { get; set; } public static IProviderManager ProviderManager { get; set; } + public static ILocalizationManager LocalizationManager { get; set; } /// /// Returns a that represents this instance. @@ -1081,9 +1082,10 @@ namespace MediaBrowser.Controller.Entities /// Determines if a given user has access to this item /// /// The user. + /// The localization manager. /// true if [is parental allowed] [the specified user]; otherwise, false. - /// - public bool IsParentalAllowed(User user) + /// user + public bool IsParentalAllowed(User user, ILocalizationManager localizationManager) { if (user == null) { @@ -1095,12 +1097,22 @@ namespace MediaBrowser.Controller.Entities return true; } - if (user.Configuration.BlockNotRated && string.IsNullOrEmpty(CustomRating ?? OfficialRating)) + var rating = CustomRating ?? OfficialRating; + + if (user.Configuration.BlockNotRated && string.IsNullOrEmpty(rating)) { return false; } - return Ratings.Level(CustomRating ?? OfficialRating) <= user.Configuration.MaxParentalRating.Value; + var value = localizationManager.GetRatingLevel(rating); + + // Could not determine the integer value + if (!value.HasValue) + { + return true; + } + + return value.Value <= user.Configuration.MaxParentalRating.Value; } /// @@ -1117,7 +1129,7 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("user"); } - return IsParentalAllowed(user); + return IsParentalAllowed(user, LocalizationManager); } /// -- cgit v1.2.3