Add "Allowed Tags" to Parental Controls
This commit is contained in:
parent
23ddeeda4c
commit
7fa6d4c81e
|
@ -231,3 +231,4 @@
|
|||
- [Matthew Jones](https://github.com/matthew-jones-uk)
|
||||
- [Jakob Kukla](https://github.com/jakobkukla)
|
||||
- [Utku Özdemir](https://github.com/utkuozdemir)
|
||||
- [JPUC1143](https://github.com/Jpuc1143/)
|
||||
|
|
|
@ -4477,6 +4477,24 @@ namespace Emby.Server.Implementations.Data
|
|||
}
|
||||
}
|
||||
|
||||
if (query.IncludeInheritedTags.Length > 0)
|
||||
{
|
||||
var paramName = "@IncludeInheritedTags";
|
||||
if (statement is null)
|
||||
{
|
||||
int index = 0;
|
||||
string includedTags = string.Join(',', query.IncludeInheritedTags.Select(_ => paramName + index++));
|
||||
whereClauses.Add("((select CleanValue from ItemValues where ItemId=Guid and Type=6 and cleanvalue in (" + includedTags + ")) is not null)");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < query.IncludeInheritedTags.Length; index++)
|
||||
{
|
||||
statement.TryBind(paramName + index, GetCleanValue(query.IncludeInheritedTags[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (query.SeriesStatuses.Length > 0)
|
||||
{
|
||||
var statuses = new List<string>();
|
||||
|
|
|
@ -63,6 +63,11 @@ namespace Jellyfin.Data.Enums
|
|||
/// <summary>
|
||||
/// A list of ordered views.
|
||||
/// </summary>
|
||||
OrderedViews = 11
|
||||
OrderedViews = 11,
|
||||
|
||||
/// <summary>
|
||||
/// A list of allowed tags.
|
||||
/// </summary>
|
||||
AllowedTags = 12
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,6 +371,7 @@ namespace Jellyfin.Server.Implementations.Users
|
|||
EnablePublicSharing = user.HasPermission(PermissionKind.EnablePublicSharing),
|
||||
AccessSchedules = user.AccessSchedules.ToArray(),
|
||||
BlockedTags = user.GetPreference(PreferenceKind.BlockedTags),
|
||||
AllowedTags = user.GetPreference(PreferenceKind.AllowedTags),
|
||||
EnabledChannels = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels),
|
||||
EnabledDevices = user.GetPreference(PreferenceKind.EnabledDevices),
|
||||
EnabledFolders = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledFolders),
|
||||
|
@ -696,6 +697,7 @@ namespace Jellyfin.Server.Implementations.Users
|
|||
// TODO: fix this at some point
|
||||
user.SetPreference(PreferenceKind.BlockUnratedItems, policy.BlockUnratedItems ?? Array.Empty<UnratedItem>());
|
||||
user.SetPreference(PreferenceKind.BlockedTags, policy.BlockedTags);
|
||||
user.SetPreference(PreferenceKind.AllowedTags, policy.AllowedTags);
|
||||
user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels);
|
||||
user.SetPreference(PreferenceKind.EnabledDevices, policy.EnabledDevices);
|
||||
user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders);
|
||||
|
|
|
@ -170,6 +170,7 @@ namespace Jellyfin.Server.Migrations.Routines
|
|||
}
|
||||
|
||||
user.SetPreference(PreferenceKind.BlockedTags, policy.BlockedTags);
|
||||
user.SetPreference(PreferenceKind.AllowedTags, policy.AllowedTags);
|
||||
user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels);
|
||||
user.SetPreference(PreferenceKind.EnabledDevices, policy.EnabledDevices);
|
||||
user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders);
|
||||
|
|
|
@ -1607,6 +1607,11 @@ namespace MediaBrowser.Controller.Entities
|
|||
return false;
|
||||
}
|
||||
|
||||
if (user.GetPreference(PreferenceKind.AllowedTags).Any() && !user.GetPreference(PreferenceKind.AllowedTags).Any(i => Tags.Contains(i, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
EnableTotalRecordCount = true;
|
||||
ExcludeArtistIds = Array.Empty<Guid>();
|
||||
ExcludeInheritedTags = Array.Empty<string>();
|
||||
IncludeInheritedTags = Array.Empty<string>();
|
||||
ExcludeItemIds = Array.Empty<Guid>();
|
||||
ExcludeItemTypes = Array.Empty<BaseItemKind>();
|
||||
ExcludeTags = Array.Empty<string>();
|
||||
|
@ -95,6 +96,8 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public string[] ExcludeInheritedTags { get; set; }
|
||||
|
||||
public string[] IncludeInheritedTags { get; set; }
|
||||
|
||||
public IReadOnlyList<string> Genres { get; set; }
|
||||
|
||||
public bool? IsSpecialSeason { get; set; }
|
||||
|
@ -368,6 +371,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
}
|
||||
|
||||
ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
|
||||
IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags);
|
||||
|
||||
User = user;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace MediaBrowser.Model.Users
|
|||
EnableSharedDeviceControl = true;
|
||||
|
||||
BlockedTags = Array.Empty<string>();
|
||||
AllowedTags = Array.Empty<string>();
|
||||
BlockUnratedItems = Array.Empty<UnratedItem>();
|
||||
|
||||
EnableUserPreferenceAccess = true;
|
||||
|
@ -86,6 +87,8 @@ namespace MediaBrowser.Model.Users
|
|||
|
||||
public string[] BlockedTags { get; set; }
|
||||
|
||||
public string[] AllowedTags { get; set; }
|
||||
|
||||
public bool EnableUserPreferenceAccess { get; set; }
|
||||
|
||||
public AccessSchedule[] AccessSchedules { get; set; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user