mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 04:19:04 +08:00
Media Library: Fixing that recent items were not displayed for users with ManageOwnMedia permission. Fixes #6446
This commit is contained in:
@@ -56,11 +56,13 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
explorer.Weld(new MediaLibraryExplorerPart());
|
||||
|
||||
var explorerShape = Services.ContentManager.BuildDisplay(explorer);
|
||||
var rootMediaFolderPath = rootMediaFolder == null ? null : rootMediaFolder.MediaPath;
|
||||
|
||||
var viewModel = new MediaManagerIndexViewModel {
|
||||
DialogMode = dialog,
|
||||
FolderPath = folderPath,
|
||||
ChildFoldersViewModel = new MediaManagerChildFoldersViewModel{Children = _mediaLibraryService.GetMediaFolders(rootMediaFolder == null ? null : rootMediaFolder.MediaPath)},
|
||||
RootFolderPath = rootMediaFolderPath,
|
||||
ChildFoldersViewModel = new MediaManagerChildFoldersViewModel { Children = _mediaLibraryService.GetMediaFolders(rootMediaFolderPath) },
|
||||
MediaTypes = _mediaLibraryService.GetMediaTypes(),
|
||||
CustomActionsShapes = explorerShape.Actions,
|
||||
CustomNavigationShapes = explorerShape.Navigation,
|
||||
@@ -158,8 +160,8 @@ namespace Orchard.MediaLibrary.Controllers {
|
||||
|
||||
var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();
|
||||
var rootMediaFolderPath = rootMediaFolder == null ? null : rootMediaFolder.MediaPath;
|
||||
var mediaParts = _mediaLibraryService.GetMediaContentItems(rootMediaFolderPath, skip, count, order, mediaType);
|
||||
var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(rootMediaFolderPath, mediaType);
|
||||
var mediaParts = _mediaLibraryService.GetMediaContentItemsRecursive(rootMediaFolderPath, skip, count, order, mediaType);
|
||||
var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCountRecursive(rootMediaFolderPath, mediaType);
|
||||
|
||||
|
||||
var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
|
||||
|
||||
@@ -434,7 +434,7 @@ $(function () {
|
||||
|
||||
ko.applyBindings(viewModel);
|
||||
|
||||
if (settings.hasFolderPath) {
|
||||
if (settings.hasFolderPath && settings.folderPath != settings.rootFolderPath) {
|
||||
viewModel.displayFolder(settings.folderPath);
|
||||
|
||||
//fetch displayed folder structure
|
||||
|
||||
@@ -13,8 +13,10 @@ namespace Orchard.MediaLibrary.Services {
|
||||
IContentQuery<MediaPart, MediaPartRecord> GetMediaContentItems(VersionOptions versionOptions = null);
|
||||
IEnumerable<MediaPart> GetMediaContentItems(string folderPath, int skip, int count, string order, string mediaType, VersionOptions versionOptions = null);
|
||||
IEnumerable<MediaPart> GetMediaContentItems(int skip, int count, string order, string mediaType, VersionOptions versionOptions = null);
|
||||
IEnumerable<MediaPart> GetMediaContentItemsRecursive(string folderPath, int skip, int count, string order, string mediaType, VersionOptions versionOptions = null);
|
||||
int GetMediaContentItemsCount(string folderPath, string mediaType, VersionOptions versionOptions = null);
|
||||
int GetMediaContentItemsCount(string mediaType, VersionOptions versionOptions = null);
|
||||
int GetMediaContentItemsCountRecursive(string folderPath, string mediaType, VersionOptions versionOptions = null);
|
||||
MediaPart ImportMedia(string relativePath, string filename);
|
||||
MediaPart ImportMedia(string relativePath, string filename, string contentType);
|
||||
MediaPart ImportMedia(Stream stream, string relativePath, string filename);
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace Orchard.MediaLibrary.Services {
|
||||
return GetMediaContentItems(null, skip, count, order, mediaType, versionOptions);
|
||||
}
|
||||
|
||||
public IEnumerable<MediaPart> GetMediaContentItemsRecursive(string folderPath, int skip, int count, string order, string mediaType, VersionOptions versionOptions = null) {
|
||||
return BuildGetMediaContentItemsQuery(_orchardServices.ContentManager, folderPath, true, order, mediaType, versionOptions)
|
||||
.Slice(skip, count);
|
||||
}
|
||||
|
||||
public int GetMediaContentItemsCount(string folderPath, string mediaType, VersionOptions versionOptions = null) {
|
||||
return BuildGetMediaContentItemsQuery(_orchardServices.ContentManager, folderPath, mediaType: mediaType, versionOptions: versionOptions)
|
||||
.Count();
|
||||
@@ -68,6 +73,11 @@ namespace Orchard.MediaLibrary.Services {
|
||||
return GetMediaContentItemsCount(null, mediaType, versionOptions);
|
||||
}
|
||||
|
||||
public int GetMediaContentItemsCountRecursive(string folderPath, string mediaType, VersionOptions versionOptions = null) {
|
||||
return BuildGetMediaContentItemsQuery(_orchardServices.ContentManager, folderPath, true, mediaType: mediaType, versionOptions: versionOptions)
|
||||
.Count();
|
||||
}
|
||||
|
||||
private static IContentQuery<MediaPart> BuildGetMediaContentItemsQuery(
|
||||
IContentManager contentManager, string folderPath = null, bool recursive = false, string order = null, string mediaType = null, VersionOptions versionOptions = null) {
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Orchard.MediaLibrary.ViewModels {
|
||||
public class MediaManagerIndexViewModel {
|
||||
public MediaManagerChildFoldersViewModel ChildFoldersViewModel { get; set; }
|
||||
public string FolderPath { get; set; }
|
||||
public string RootFolderPath { get; set; }
|
||||
public bool DialogMode { get; set; }
|
||||
public IEnumerable<ContentTypeDefinition> MediaTypes { get; set; }
|
||||
public dynamic CustomActionsShapes { get; set; }
|
||||
|
||||
@@ -98,6 +98,7 @@ var mediaLibrarySettings = {
|
||||
cloneActionUrl: '@Url.Action("Clone", "Admin", new {area = "Orchard.MediaLibrary"})',
|
||||
hasFolderPath: @(!string.IsNullOrEmpty(viewModel.FolderPath) ? "true" : "false"),
|
||||
folderPath: '@HttpUtility.JavaScriptStringEncode(viewModel.FolderPath)',
|
||||
rootFolderPath: '@HttpUtility.JavaScriptStringEncode(viewModel.RootFolderPath ?? "")',
|
||||
deleteConfirmationMessage: '@HttpUtility.JavaScriptStringEncode(T("Are you sure you want to delete these media items ?").Text)',
|
||||
cloneConfirmationMessage: '@HttpUtility.JavaScriptStringEncode(T("Are you sure you want to clone this media item ?").Text)',
|
||||
errorMessage: '@HttpUtility.JavaScriptStringEncode(T("An unexpected error occured, please refresh the page and try again.").Text)',
|
||||
|
||||
Reference in New Issue
Block a user