public ActionResult Index(string folderPath = "", bool dialog = false) { if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath)) { Services.Notifier.Add(UI.Notify.NotifyType.Error, T("Cannot select media")); return(new HttpUnauthorizedResult()); } var userMediaFolder = _mediaLibraryService.GetUserMediaFolder(); if (Services.Authorizer.Authorize(Permissions.ManageOwnMedia) && !Services.Authorizer.Authorize(Permissions.ManageMediaContent)) { _storageProvider.TryCreateFolder(userMediaFolder.MediaPath); } // If the user is trying to access a folder above his boundaries, redirect him to his home folder var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder(); if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath) && !_mediaLibraryService.CanManageMediaFolder(folderPath)) { return(RedirectToAction("Index", new { folderPath = rootMediaFolder.MediaPath, dialog })); } // let other modules enhance the ui by providing custom navigation and actions var explorer = Services.ContentManager.New("MediaLibraryExplorer"); 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, RootFolderPath = rootMediaFolderPath, ChildFoldersViewModel = new MediaManagerChildFoldersViewModel { Children = _mediaLibraryService.GetMediaFolders(rootMediaFolderPath) }, MediaTypes = _mediaLibraryService.GetMediaTypes(), CustomActionsShapes = explorerShape.Actions, CustomNavigationShapes = explorerShape.Navigation, }; foreach (var shape in explorerShape.Actions.Items) { shape.MediaManagerIndexViewModel = viewModel; } foreach (var shape in explorerShape.Navigation.Items) { shape.MediaManagerIndexViewModel = viewModel; } return(View(viewModel)); }