aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-16 02:10:55 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-16 02:10:55 -0400
commit4ef9f68837d0c2d2b371239d8568edb6473c6072 (patch)
tree8932031cbdc4cf46a7ef6b03a013345fdf3aba21 /MediaBrowser.Controller
parent6f15141d73aae2fa78511077580fdc2cd895694f (diff)
support delete per library
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs28
-rw-r--r--MediaBrowser.Controller/Entities/Movies/BoxSet.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs2
-rw-r--r--MediaBrowser.Controller/Notifications/INotificationManager.cs3
-rw-r--r--MediaBrowser.Controller/Playlists/Playlist.cs2
6 files changed, 32 insertions, 7 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 46c037a44d..051a2cbcad 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -477,14 +477,36 @@ namespace MediaBrowser.Controller.Entities
locationType != LocationType.Virtual;
}
- public virtual bool IsAuthorizedToDelete(User user)
+ public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
{
- return user.Policy.EnableContentDeletion;
+ if (user.Policy.EnableContentDeletion)
+ {
+ return true;
+ }
+
+ var allowed = user.Policy.EnableContentDeletionFromFolders;
+ var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
+
+ foreach (var folder in collectionFolders)
+ {
+ if (allowed.Contains(folder.Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public bool CanDelete(User user, List<Folder> allCollectionFolders)
+ {
+ return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
}
public bool CanDelete(User user)
{
- return CanDelete() && IsAuthorizedToDelete(user);
+ var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
+ return CanDelete(user, allCollectionFolders);
}
public virtual bool CanDownload()
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
index bd8d9024d4..0067515d88 100644
--- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
+++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
@@ -126,7 +126,7 @@ namespace MediaBrowser.Controller.Entities.Movies
}
}
- public override bool IsAuthorizedToDelete(User user)
+ public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
{
return true;
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
index 2dfc59d228..bd84541f8f 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
@@ -132,7 +132,7 @@ namespace MediaBrowser.Controller.LiveTv
return true;
}
- public override bool IsAuthorizedToDelete(User user)
+ public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
{
return user.Policy.EnableLiveTvManagement;
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
index 1dfed4f75d..37c1faac6e 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
@@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.LiveTv
return true;
}
- public override bool IsAuthorizedToDelete(User user)
+ public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
{
return user.Policy.EnableLiveTvManagement;
}
diff --git a/MediaBrowser.Controller/Notifications/INotificationManager.cs b/MediaBrowser.Controller/Notifications/INotificationManager.cs
index f9d2643145..68cfd6ff1b 100644
--- a/MediaBrowser.Controller/Notifications/INotificationManager.cs
+++ b/MediaBrowser.Controller/Notifications/INotificationManager.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Notifications
{
@@ -15,6 +16,8 @@ namespace MediaBrowser.Controller.Notifications
/// <returns>Task.</returns>
Task SendNotification(NotificationRequest request, CancellationToken cancellationToken);
+ Task SendNotification(NotificationRequest request, BaseItem relatedItem, CancellationToken cancellationToken);
+
/// <summary>
/// Adds the parts.
/// </summary>
diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs
index ee96a8c3b7..071f8a0961 100644
--- a/MediaBrowser.Controller/Playlists/Playlist.cs
+++ b/MediaBrowser.Controller/Playlists/Playlist.cs
@@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Playlists
return 1;
}
- public override bool IsAuthorizedToDelete(User user)
+ public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
{
return true;
}