public ActionResult Edit() { if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Couldn't edit media folder"))) return new HttpUnauthorizedResult(); var viewModel = new MediaManagerFolderEditViewModel(); UpdateModel(viewModel); try { _mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name); var segments = viewModel.FolderPath.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries).ToArray(); var newFolderPath = String.Join(Path.DirectorySeparatorChar.ToString(), segments.Take(segments.Length - 1).Union(new [] { viewModel.Name })); foreach (var media in Services.ContentManager.Query().ForPart<MediaPart>().Where<MediaPartRecord>(m => m.FolderPath.StartsWith(viewModel.FolderPath)).List()) { media.FolderPath = newFolderPath + media.FolderPath.Substring(viewModel.FolderPath.Length); } Services.Notifier.Information(T("Media folder renamed")); } catch (ArgumentException argumentException) { Services.Notifier.Error(T("Editing Folder failed: {0}", argumentException.Message)); Services.TransactionManager.Cancel(); return View(viewModel); } return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" }); }
public ActionResult Edit(string folderPath) { if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Couldn't edit media folder"))) return new HttpUnauthorizedResult(); var viewModel = new MediaManagerFolderEditViewModel { FolderPath = folderPath, Name = folderPath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last() }; return View(viewModel); }
public ActionResult Edit(int id) { if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Couldn't edit media folder"))) return new HttpUnauthorizedResult(); var folder = _mediaLibraryService.GetMediaFolder(id); var viewModel = new MediaManagerFolderEditViewModel { Hierarchy = _mediaLibraryService.GetMediaFolderHierarchy(id), FolderId = id, Name = folder.Name }; return View(viewModel); }
public ActionResult Edit() { if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Couldn't edit media folder"))) return new HttpUnauthorizedResult(); var viewModel = new MediaManagerFolderEditViewModel(); UpdateModel(viewModel); try { _mediaLibraryService.RenameFolder(viewModel.FolderPath, viewModel.Name); Services.Notifier.Information(T("Media folder renamed")); } catch (Exception exception) { Services.Notifier.Error(T("Editing Folder failed: {0}", exception.Message)); return View(viewModel); } return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" }); }
public ActionResult Edit(string folderPath) { if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Couldn't edit media folder"))) return new HttpUnauthorizedResult(); if (!_mediaLibraryService.CanManageMediaFolder(folderPath)) { return new HttpUnauthorizedResult(); } // Shouldn't be able to rename the root folder if (IsRootFolder(folderPath)) { return new HttpUnauthorizedResult(); } var viewModel = new MediaManagerFolderEditViewModel { FolderPath = folderPath, Name = folderPath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last() }; return View(viewModel); }
public ActionResult Delete() { if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Couldn't delete media folder"))) return new HttpUnauthorizedResult(); var viewModel = new MediaManagerFolderEditViewModel(); UpdateModel(viewModel); if (!_mediaLibraryService.CanManageMediaFolder(viewModel.FolderPath)) { return new HttpUnauthorizedResult(); } try { _mediaLibraryService.DeleteFolder(viewModel.FolderPath); Services.Notifier.Information(T("Media folder deleted")); } catch (ArgumentException argumentException) { Services.Notifier.Error(T("Deleting Folder failed: {0}", argumentException.Message)); Services.TransactionManager.Cancel(); return View(viewModel); } return RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" }); }