From 6e5d90bafe3eca21e64b0a04deba4afee98b2cfa Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 21 Feb 2014 10:24:29 -0500 Subject: [PATCH] rework checkboxes for block unrated items --- .../Entities/Audio/Audio.cs | 2 +- .../Entities/Audio/MusicAlbum.cs | 2 +- .../Entities/Audio/MusicArtist.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- MediaBrowser.Controller/Entities/Book.cs | 2 +- MediaBrowser.Controller/Entities/Game.cs | 3 +- .../Entities/Movies/BoxSet.cs | 2 +- .../Entities/Movies/Movie.cs | 2 +- .../Entities/MusicVideo.cs | 3 +- .../Entities/TV/Episode.cs | 2 +- MediaBrowser.Controller/Entities/TV/Series.cs | 2 +- MediaBrowser.Controller/Entities/Trailer.cs | 3 +- .../LiveTv/LiveTvAudioRecording.cs | 7 +++++ .../LiveTv/LiveTvChannel.cs | 7 +++++ .../LiveTv/LiveTvProgram.cs | 7 +++++ .../LiveTv/LiveTvVideoRecording.cs | 7 +++++ .../Configuration/UserConfiguration.cs | 30 ++++++++++--------- 17 files changed, 59 insertions(+), 26 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 836874db9..73e276f3b 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -135,7 +135,7 @@ namespace MediaBrowser.Controller.Entities.Audio protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedMusic; + return config.BlockUnratedItems.Contains(UnratedItem.Music); } public SongInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 51c8a8727..bc260c696 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Entities.Audio protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedMusic; + return config.BlockUnratedItems.Contains(UnratedItem.Music); } public AlbumInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 27e164307..11cf441f7 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -123,7 +123,7 @@ namespace MediaBrowser.Controller.Entities.Audio protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedMusic; + return config.BlockUnratedItems.Contains(UnratedItem.Music); } public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress progress, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 483ed1c34..9d520cf6f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -895,7 +895,7 @@ namespace MediaBrowser.Controller.Entities /// true if XXXX, false otherwise. protected virtual bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockNotRated; + return config.BlockUnratedItems.Contains(UnratedItem.Other); } /// diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index 0405fc484..29d6e4084 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -38,7 +38,7 @@ namespace MediaBrowser.Controller.Entities protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedBooks; + return config.BlockUnratedItems.Contains(UnratedItem.Book); } public BookInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index cc9d9a1a4..e490a59cd 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -3,6 +3,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -107,7 +108,7 @@ namespace MediaBrowser.Controller.Entities protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedGames; + return config.BlockUnratedItems.Contains(UnratedItem.Game); } public GameInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 6cd078677..b0cb549f4 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.Entities.Movies protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedMovies; + return config.BlockUnratedItems.Contains(UnratedItem.Movie); } public override IEnumerable GetChildren(User user, bool includeLinkedChildren) diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 846a2ae7b..9858dd5a9 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -160,7 +160,7 @@ namespace MediaBrowser.Controller.Entities.Movies protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedMovies; + return config.BlockUnratedItems.Contains(UnratedItem.Movie); } public MovieInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 56cd71d49..c3c4b89ba 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -3,6 +3,7 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -53,7 +54,7 @@ namespace MediaBrowser.Controller.Entities protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedMusic; + return config.BlockUnratedItems.Contains(UnratedItem.Music); } public MusicVideoInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 1240bbb9f..8784a7187 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -244,7 +244,7 @@ namespace MediaBrowser.Controller.Entities.TV protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedSeries; + return config.BlockUnratedItems.Contains(UnratedItem.Series); } public EpisodeInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index d1d393e3e..be6c92864 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -217,7 +217,7 @@ namespace MediaBrowser.Controller.Entities.TV protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedSeries; + return config.BlockUnratedItems.Contains(UnratedItem.Series); } public string PreferredMetadataLanguage { get; set; } diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 50ccd060b..2a09536c0 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -4,6 +4,7 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Runtime.Serialization; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -97,7 +98,7 @@ namespace MediaBrowser.Controller.Entities protected override bool GetBlockUnratedValue(UserConfiguration config) { - return config.BlockUnratedTrailers; + return config.BlockUnratedItems.Contains(UnratedItem.Trailer); } public TrailerInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index a4a85ec04..9f8d67a48 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -1,5 +1,7 @@ using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using System.Linq; namespace MediaBrowser.Controller.LiveTv { @@ -75,5 +77,10 @@ namespace MediaBrowser.Controller.LiveTv return false; } } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram); + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 583b90fd4..ff5d6a4d2 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -1,8 +1,10 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.LiveTv; using System.Collections.Generic; using System.Runtime.Serialization; +using System.Linq; namespace MediaBrowser.Controller.LiveTv { @@ -38,6 +40,11 @@ namespace MediaBrowser.Controller.LiveTv } } + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.LiveTvChannel); + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index e7a501479..266eaabee 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -1,9 +1,11 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.LiveTv; using System; using System.Threading; using System.Threading.Tasks; +using System.Linq; namespace MediaBrowser.Controller.LiveTv { @@ -196,5 +198,10 @@ namespace MediaBrowser.Controller.LiveTv // Not great that this class has to know about that, but we'll improve that later. return ItemRepository.SaveItem(this, cancellationToken); } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram); + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 6e3644b4a..66de81213 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -1,5 +1,7 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using System.Linq; namespace MediaBrowser.Controller.LiveTv { @@ -75,5 +77,10 @@ namespace MediaBrowser.Controller.LiveTv return false; } } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram); + } } } diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index fa2554e05..2145860c7 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -12,12 +12,6 @@ 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 this instance is administrator. /// @@ -54,13 +48,6 @@ namespace MediaBrowser.Model.Configuration public bool DisplayUnairedEpisodes { get; set; } public bool EnableRemoteControlOfOtherUsers { get; set; } - public bool BlockUnratedMovies { get; set; } - public bool BlockUnratedTrailers { get; set; } - public bool BlockUnratedSeries { get; set; } - public bool BlockUnratedMusic { get; set; } - public bool BlockUnratedGames { get; set; } - public bool BlockUnratedBooks { get; set; } - public bool EnableLiveTvManagement { get; set; } public bool EnableLiveTvAccess { get; set; } @@ -68,6 +55,8 @@ namespace MediaBrowser.Model.Configuration public string[] BlockedMediaFolders { get; set; } + public UnratedItem[] BlockUnratedItems { get; set; } + /// /// Initializes a new instance of the class. /// @@ -75,13 +64,26 @@ namespace MediaBrowser.Model.Configuration { IsAdministrator = true; EnableRemoteControlOfOtherUsers = true; - BlockNotRated = false; EnableLiveTvManagement = true; EnableMediaPlayback = true; EnableLiveTvAccess = true; BlockedMediaFolders = new string[] { }; + BlockUnratedItems = new UnratedItem[] { }; } } + + public enum UnratedItem + { + Movie, + Trailer, + Series, + Music, + Game, + Book, + LiveTvChannel, + LiveTvProgram, + Other + } }