From b70ecab40a4d83cab0c1bd9a42891640c5e006a7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 8 Jul 2013 15:31:45 -0400 Subject: [PATCH] fixes for new user settings --- MediaBrowser.Api/UserService.cs | 11 ++++++++-- MediaBrowser.Controller/Dto/DtoBuilder.cs | 20 ++++++++++++++++--- MediaBrowser.Model/ApiClient/IApiClient.cs | 8 ++++++++ .../Configuration/ManualLoginCategory.cs | 3 +-- MediaBrowser.Model/Dto/BaseItemDto.cs | 12 +++++++++++ .../ApplicationHost.cs | 4 ++-- 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index b63bafbc0d..8eb55c786e 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -197,7 +197,8 @@ namespace MediaBrowser.Api { return Get(new GetUsers { - IsHidden = false + IsHidden = false, + IsDisabled = false }); } @@ -367,7 +368,13 @@ namespace MediaBrowser.Api } } - // If removing admin access + // If disabling + if (dtoUser.Configuration.IsDisabled && user.Configuration.IsAdministrator) + { + throw new ArgumentException("Administrators cannot be disabled."); + } + + // If disabling if (dtoUser.Configuration.IsDisabled && !user.Configuration.IsDisabled) { if (_userManager.Users.Count(i => !i.Configuration.IsDisabled) == 1) diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index 6df8f1aed6..d1a0465cd3 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -364,7 +364,7 @@ namespace MediaBrowser.Controller.Dto // If there is no logo, indicate what parent has one in case the Ui wants to allow inheritance if (!dto.HasLogo) { - var parentWithLogo = GetParentLogoItem(item); + var parentWithLogo = GetParentImageItem(item, ImageType.Logo); if (parentWithLogo != null) { @@ -374,6 +374,19 @@ namespace MediaBrowser.Controller.Dto } } + // If there is no art, indicate what parent has one in case the Ui wants to allow inheritance + if (!dto.HasArtImage) + { + var parentWithImage = GetParentImageItem(item, ImageType.Art); + + if (parentWithImage != null) + { + dto.ParentLogoItemId = GetClientItemId(parentWithImage); + + dto.ParentLogoImageTag = GetImageCacheTag(parentWithImage, ImageType.Art, parentWithImage.GetImage(ImageType.Art)); + } + } + if (fields.Contains(ItemFields.Path)) { dto.Path = item.Path; @@ -751,14 +764,15 @@ namespace MediaBrowser.Controller.Dto /// If an item does not have a logo, this can be used to find the first parent that does have one /// /// The item. + /// The type. /// BaseItem. - private BaseItem GetParentLogoItem(BaseItem item) + private BaseItem GetParentImageItem(BaseItem item, ImageType type) { var parent = item.Parent; while (parent != null) { - if (parent.HasImage(ImageType.Logo)) + if (parent.HasImage(type)) { return parent; } diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 5ecb87b5a4..fb4e8b406b 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -640,6 +640,14 @@ namespace MediaBrowser.Model.ApiClient /// item string GetLogoImageUrl(BaseItemDto item, ImageOptions options); + /// + /// Gets the art image URL. + /// + /// The item. + /// The options. + /// System.String. + string GetArtImageUrl(BaseItemDto item, ImageOptions options); + /// /// Gets the url needed to stream an audio file /// diff --git a/MediaBrowser.Model/Configuration/ManualLoginCategory.cs b/MediaBrowser.Model/Configuration/ManualLoginCategory.cs index 20e873437c..37b6d6c82f 100644 --- a/MediaBrowser.Model/Configuration/ManualLoginCategory.cs +++ b/MediaBrowser.Model/Configuration/ManualLoginCategory.cs @@ -4,7 +4,6 @@ namespace MediaBrowser.Model.Configuration public enum ManualLoginCategory { Mobile, - MediaBrowserTheater, - Roku + MediaBrowserTheater } } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 1494795dab..dca2cef87f 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -416,6 +416,18 @@ namespace MediaBrowser.Model.Dto /// The parent logo image tag. public Guid? ParentLogoImageTag { get; set; } + /// + /// If the item does not have a art, this will hold the Id of the Parent that has one. + /// + /// The parent art item id. + public string ParentArtItemId { get; set; } + + /// + /// Gets or sets the parent art image tag. + /// + /// The parent art image tag. + public Guid? ParentArtImageTag { get; set; } + /// /// Gets or sets the chapters. /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 2f78f0d8f6..9b18826e3d 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -1,5 +1,4 @@ -using System.Threading; -using MediaBrowser.Api; +using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Constants; @@ -53,6 +52,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.ServerApplication