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