2015-08-14 19:24:07 +02:00
|
|
|
|
using MediaBrowser.Controller.Playlists;
|
2015-03-14 05:50:23 +01:00
|
|
|
|
using MediaBrowser.Controller.TV;
|
2014-06-05 04:32:40 +02:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-09-01 22:10:54 +02:00
|
|
|
|
using MediaBrowser.Model.Querying;
|
2014-06-05 04:32:40 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-10-25 21:02:04 +02:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2014-08-14 15:24:30 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2015-11-02 18:25:01 +01:00
|
|
|
|
using System.Linq;
|
2017-05-21 09:25:49 +02:00
|
|
|
|
using MediaBrowser.Controller.Dto;
|
2014-06-05 04:32:40 +02:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
|
{
|
|
|
|
|
public class UserView : Folder
|
|
|
|
|
{
|
|
|
|
|
public string ViewType { get; set; }
|
2015-10-16 06:46:41 +02:00
|
|
|
|
public Guid DisplayParentId { get; set; }
|
2014-06-05 04:32:40 +02:00
|
|
|
|
|
2015-08-14 20:30:08 +02:00
|
|
|
|
public Guid? UserId { get; set; }
|
2015-11-08 06:04:38 +01:00
|
|
|
|
|
2014-09-01 22:10:54 +02:00
|
|
|
|
public static ITVSeriesManager TVSeriesManager;
|
2015-03-14 05:50:23 +01:00
|
|
|
|
public static IPlaylistManager PlaylistManager;
|
2014-09-01 22:10:54 +02:00
|
|
|
|
|
2015-10-29 14:28:05 +01:00
|
|
|
|
public override IEnumerable<Guid> GetIdsForAncestorQuery()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<Guid>();
|
|
|
|
|
|
|
|
|
|
if (DisplayParentId != Guid.Empty)
|
|
|
|
|
{
|
|
|
|
|
list.Add(DisplayParentId);
|
|
|
|
|
}
|
|
|
|
|
else if (ParentId != Guid.Empty)
|
|
|
|
|
{
|
|
|
|
|
list.Add(ParentId);
|
|
|
|
|
}
|
2015-11-11 15:56:31 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.Add(Id);
|
|
|
|
|
}
|
2015-10-29 14:28:05 +01:00
|
|
|
|
return list;
|
|
|
|
|
}
|
2015-11-08 06:04:38 +01:00
|
|
|
|
|
2017-06-29 21:10:58 +02:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override bool SupportsInheritedParentImages
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-11 08:46:59 +02:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override bool SupportsPlayedStatus
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-16 15:24:12 +02:00
|
|
|
|
public override int GetChildCount(User user)
|
|
|
|
|
{
|
|
|
|
|
return GetChildren(user, true).Count();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 08:48:54 +02:00
|
|
|
|
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
|
2014-06-05 04:32:40 +02:00
|
|
|
|
{
|
2014-10-29 23:01:02 +01:00
|
|
|
|
var parent = this as Folder;
|
|
|
|
|
|
2015-10-16 06:46:41 +02:00
|
|
|
|
if (DisplayParentId != Guid.Empty)
|
|
|
|
|
{
|
|
|
|
|
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
|
|
|
|
|
}
|
|
|
|
|
else if (ParentId != Guid.Empty)
|
2014-10-29 23:01:02 +01:00
|
|
|
|
{
|
|
|
|
|
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-05 21:44:55 +02:00
|
|
|
|
return new UserViewBuilder(UserViewManager, LiveTvManager, ChannelManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, ConfigurationManager, PlaylistManager)
|
2017-05-26 08:48:54 +02:00
|
|
|
|
.GetUserItems(parent, this, ViewType, query).Result;
|
2014-09-01 22:10:54 +02:00
|
|
|
|
}
|
2014-06-05 04:32:40 +02:00
|
|
|
|
|
2014-09-01 22:10:54 +02:00
|
|
|
|
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
|
|
|
|
{
|
2014-10-07 01:58:46 +02:00
|
|
|
|
var result = GetItems(new InternalItemsQuery
|
2014-06-05 04:32:40 +02:00
|
|
|
|
{
|
2016-05-18 07:34:10 +02:00
|
|
|
|
User = user,
|
2017-05-21 09:25:49 +02:00
|
|
|
|
EnableTotalRecordCount = false,
|
|
|
|
|
DtoOptions = new DtoOptions(true)
|
2014-08-14 15:24:30 +02:00
|
|
|
|
|
2017-05-26 08:48:54 +02:00
|
|
|
|
});
|
2014-08-14 15:24:30 +02:00
|
|
|
|
|
2014-09-01 22:10:54 +02:00
|
|
|
|
return result.Items;
|
2014-06-05 04:32:40 +02:00
|
|
|
|
}
|
2014-08-14 15:24:30 +02:00
|
|
|
|
|
2015-02-06 06:39:07 +01:00
|
|
|
|
public override bool CanDelete()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-21 14:37:27 +01:00
|
|
|
|
public override bool IsSaveLocalMetadataEnabled()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-18 07:34:10 +02:00
|
|
|
|
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
2014-08-14 15:24:30 +02:00
|
|
|
|
{
|
2014-10-07 01:58:46 +02:00
|
|
|
|
var result = GetItems(new InternalItemsQuery
|
2014-09-01 22:10:54 +02:00
|
|
|
|
{
|
|
|
|
|
User = user,
|
2015-01-25 07:34:50 +01:00
|
|
|
|
Recursive = true,
|
2016-05-18 07:34:10 +02:00
|
|
|
|
EnableTotalRecordCount = false,
|
|
|
|
|
|
2017-05-21 09:25:49 +02:00
|
|
|
|
ForceDirect = true,
|
|
|
|
|
|
|
|
|
|
DtoOptions = query.DtoOptions
|
2014-08-14 15:24:30 +02:00
|
|
|
|
|
2017-05-26 08:48:54 +02:00
|
|
|
|
});
|
2014-08-14 15:24:30 +02:00
|
|
|
|
|
2016-05-18 07:34:10 +02:00
|
|
|
|
return result.Items.Where(i => UserViewBuilder.FilterItem(i, query));
|
2014-08-14 15:24:30 +02:00
|
|
|
|
}
|
2014-06-05 04:32:40 +02:00
|
|
|
|
|
|
|
|
|
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
|
|
|
|
{
|
|
|
|
|
return GetChildren(user, false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 20:09:44 +02:00
|
|
|
|
public static bool IsUserSpecific(Folder folder)
|
|
|
|
|
{
|
|
|
|
|
var standaloneTypes = new List<string>
|
|
|
|
|
{
|
2016-09-05 22:07:36 +02:00
|
|
|
|
CollectionType.Playlists
|
2014-06-05 04:32:40 +02:00
|
|
|
|
};
|
|
|
|
|
|
2014-10-12 03:46:02 +02:00
|
|
|
|
var collectionFolder = folder as ICollectionFolder;
|
2014-06-05 04:32:40 +02:00
|
|
|
|
|
|
|
|
|
if (collectionFolder == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-14 17:58:01 +01:00
|
|
|
|
var supportsUserSpecific = folder as ISupportsUserSpecificView;
|
|
|
|
|
if (supportsUserSpecific != null && supportsUserSpecific.EnableUserSpecificView)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 04:32:40 +02:00
|
|
|
|
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
|
|
|
|
|
}
|
2015-06-29 03:10:45 +02:00
|
|
|
|
|
2015-11-18 06:49:20 +01:00
|
|
|
|
public static bool IsEligibleForGrouping(Folder folder)
|
|
|
|
|
{
|
|
|
|
|
var collectionFolder = folder as ICollectionFolder;
|
|
|
|
|
return collectionFolder != null && IsEligibleForGrouping(collectionFolder.CollectionType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsEligibleForGrouping(string viewType)
|
|
|
|
|
{
|
|
|
|
|
var types = new[]
|
|
|
|
|
{
|
|
|
|
|
CollectionType.Movies,
|
|
|
|
|
CollectionType.TvShows,
|
|
|
|
|
string.Empty
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-14 18:05:08 +01:00
|
|
|
|
public static bool EnableOriginalFolder(string viewType)
|
|
|
|
|
{
|
|
|
|
|
var types = new[]
|
|
|
|
|
{
|
|
|
|
|
CollectionType.Games,
|
|
|
|
|
CollectionType.Books,
|
2015-11-14 20:56:56 +01:00
|
|
|
|
CollectionType.MusicVideos,
|
|
|
|
|
CollectionType.HomeVideos,
|
2015-11-16 23:03:11 +01:00
|
|
|
|
CollectionType.Photos,
|
|
|
|
|
CollectionType.Music,
|
|
|
|
|
CollectionType.BoxSets
|
2015-11-14 18:05:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-08 06:04:38 +01:00
|
|
|
|
protected override Task ValidateChildrenInternal(IProgress<double> progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(true);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 03:10:45 +02:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override bool SupportsPeople
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-05 04:32:40 +02:00
|
|
|
|
}
|
|
|
|
|
}
|