From 8452e2f1250b37aa6584faed2bb9d36ddef0a1b2 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 23 May 2013 11:07:25 -0400 Subject: [PATCH] Add block unrated option --- MediaBrowser.Controller/Entities/BaseItem.cs | 5 +++++ MediaBrowser.Controller/Entities/Folder.cs | 15 +++++++++++++++ .../Configuration/UserConfiguration.cs | 7 +++++++ MediaBrowser.ServerApplication/App.config | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 10b3aa722..ac8688f77 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1072,6 +1072,11 @@ namespace MediaBrowser.Controller.Entities return true; } + if (user.Configuration.BlockNotRated && string.IsNullOrEmpty(CustomRating ?? OfficialRating)) + { + return false; + } + return Ratings.Level(CustomRating ?? OfficialRating) <= user.Configuration.MaxParentalRating.Value; } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 16bfff564..284994657 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -120,6 +120,21 @@ namespace MediaBrowser.Controller.Entities await LibraryManager.SaveChildren(Id, newChildren, cancellationToken).ConfigureAwait(false); } + /// + /// Never want folders to be blocked by "BlockNotRated" + /// + public override string OfficialRating + { + get + { + return !string.IsNullOrEmpty(base.OfficialRating) ? base.OfficialRating : "None"; + } + set + { + base.OfficialRating = value; + } + } + /// /// Removes the child. /// diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index deb6fdb3d..792ef574f 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -12,6 +12,12 @@ namespace MediaBrowser.Model.Configuration /// The max parental rating. public int? MaxParentalRating { get; set; } + /// + /// Gets or sets a value indicating whether items with no rating information should be blocked. + /// + /// true if items with no rating info should be blocked; otherwise, false. + public bool BlockNotRated { get; set; } + /// /// Gets or sets a value indicating whether [use custom library]. /// @@ -48,6 +54,7 @@ namespace MediaBrowser.Model.Configuration public UserConfiguration() { IsAdministrator = true; + BlockNotRated = true; } } } diff --git a/MediaBrowser.ServerApplication/App.config b/MediaBrowser.ServerApplication/App.config index ca35b353c..06fe8b439 100644 --- a/MediaBrowser.ServerApplication/App.config +++ b/MediaBrowser.ServerApplication/App.config @@ -10,7 +10,7 @@ - +