mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Making some service references more consistent
Several admin controllers referenced INotifier, IAuthorizer, and IContentManager as individual services rather than as the general IOrchardServices carrier. Some extra namespaces also removed. --HG-- branch : dev
This commit is contained in:
@@ -15,17 +15,15 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly IThemeService _themeService;
|
private readonly IThemeService _themeService;
|
||||||
private readonly IPreviewTheme _previewTheme;
|
private readonly IPreviewTheme _previewTheme;
|
||||||
private readonly IAuthorizer _authorizer;
|
|
||||||
private readonly INotifier _notifier;
|
|
||||||
|
|
||||||
public AdminController(IThemeService themeService, IPreviewTheme previewTheme, IAuthorizer authorizer, INotifier notifier) {
|
public AdminController(IOrchardServices services, IThemeService themeService, IPreviewTheme previewTheme, IAuthorizer authorizer, INotifier notifier) {
|
||||||
|
Services = services;
|
||||||
_themeService = themeService;
|
_themeService = themeService;
|
||||||
_previewTheme = previewTheme;
|
_previewTheme = previewTheme;
|
||||||
_authorizer = authorizer;
|
|
||||||
_notifier = notifier;
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IOrchardServices Services{ get; set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
@@ -36,7 +34,7 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Listing themes failed: " + exception.Message));
|
Services.Notifier.Error(T("Listing themes failed: " + exception.Message));
|
||||||
return View(new ThemesIndexViewModel());
|
return View(new ThemesIndexViewModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,13 +42,13 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
[HttpPost, FormValueAbsent("submit.Apply"), FormValueAbsent("submit.Cancel")]
|
[HttpPost, FormValueAbsent("submit.Apply"), FormValueAbsent("submit.Cancel")]
|
||||||
public ActionResult Preview(string themeName, string returnUrl) {
|
public ActionResult Preview(string themeName, string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_previewTheme.SetPreviewTheme(themeName);
|
_previewTheme.SetPreviewTheme(themeName);
|
||||||
return Redirect(returnUrl ?? "~/");
|
return Redirect(returnUrl ?? "~/");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Previewing theme failed: " + exception.Message));
|
Services.Notifier.Error(T("Previewing theme failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,14 +56,14 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
[HttpPost, ActionName("Preview"), FormValueRequired("submit.Apply")]
|
[HttpPost, ActionName("Preview"), FormValueRequired("submit.Apply")]
|
||||||
public ActionResult ApplyPreview(string themeName, string returnUrl) {
|
public ActionResult ApplyPreview(string themeName, string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_previewTheme.SetPreviewTheme(null);
|
_previewTheme.SetPreviewTheme(null);
|
||||||
_themeService.SetSiteTheme(themeName);
|
_themeService.SetSiteTheme(themeName);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Previewing theme failed: " + exception.Message));
|
Services.Notifier.Error(T("Previewing theme failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,13 +71,13 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
[HttpPost, ActionName("Preview"), FormValueRequired("submit.Cancel")]
|
[HttpPost, ActionName("Preview"), FormValueRequired("submit.Cancel")]
|
||||||
public ActionResult CancelPreview(string returnUrl) {
|
public ActionResult CancelPreview(string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_previewTheme.SetPreviewTheme(null);
|
_previewTheme.SetPreviewTheme(null);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Previewing theme failed: " + exception.Message));
|
Services.Notifier.Error(T("Previewing theme failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,13 +85,13 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Activate(string themeName) {
|
public ActionResult Activate(string themeName) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't set the current theme")))
|
if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't set the current theme")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_themeService.SetSiteTheme(themeName);
|
_themeService.SetSiteTheme(themeName);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Activating theme failed: " + exception.Message));
|
Services.Notifier.Error(T("Activating theme failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +103,7 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Install(FormCollection input) {
|
public ActionResult Install(FormCollection input) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageThemes, T("Couldn't install theme")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageThemes, T("Couldn't install theme")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
foreach (string fileName in Request.Files) {
|
foreach (string fileName in Request.Files) {
|
||||||
HttpPostedFileBase file = Request.Files[fileName];
|
HttpPostedFileBase file = Request.Files[fileName];
|
||||||
@@ -114,7 +112,7 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Installing theme failed: " + exception.Message));
|
Services.Notifier.Error(T("Installing theme failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,13 +120,13 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Uninstall(string themeName) {
|
public ActionResult Uninstall(string themeName) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageThemes, T("Couldn't uninstall theme")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageThemes, T("Couldn't uninstall theme")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_themeService.UninstallTheme(themeName);
|
_themeService.UninstallTheme(themeName);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Uninstalling theme failed: " + exception.Message));
|
Services.Notifier.Error(T("Uninstalling theme failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,48 +8,40 @@ using Orchard.Blogs.Services;
|
|||||||
using Orchard.Blogs.ViewModels;
|
using Orchard.Blogs.ViewModels;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Data;
|
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
using Orchard.Security;
|
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Controllers {
|
namespace Orchard.Blogs.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
public class BlogAdminController : Controller, IUpdateModel {
|
public class BlogAdminController : Controller, IUpdateModel {
|
||||||
private readonly IOrchardServices _services;
|
|
||||||
private readonly IBlogService _blogService;
|
private readonly IBlogService _blogService;
|
||||||
private readonly IBlogPostService _blogPostService;
|
private readonly IBlogPostService _blogPostService;
|
||||||
private readonly ISessionLocator _sessionLocator;
|
|
||||||
private readonly IAuthorizer _authorizer;
|
|
||||||
private readonly INotifier _notifier;
|
|
||||||
|
|
||||||
public BlogAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, ISessionLocator sessionLocator, IAuthorizer authorizer, INotifier notifier) {
|
public BlogAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService) {
|
||||||
_services = services;
|
Services = services;
|
||||||
_blogService = blogService;
|
_blogService = blogService;
|
||||||
_blogPostService = blogPostService;
|
_blogPostService = blogPostService;
|
||||||
_sessionLocator = sessionLocator;
|
|
||||||
_authorizer = authorizer;
|
|
||||||
_notifier = notifier;
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Localizer T { get; set; }
|
private Localizer T { get; set; }
|
||||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||||
|
public IOrchardServices Services { get; set; }
|
||||||
|
|
||||||
public ActionResult Create() {
|
public ActionResult Create() {
|
||||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||||
if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
Blog blog = _services.ContentManager.New<Blog>(BlogDriver.ContentType.Name);
|
Blog blog = Services.ContentManager.New<Blog>(BlogDriver.ContentType.Name);
|
||||||
|
|
||||||
if (blog == null)
|
if (blog == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var model = new CreateBlogViewModel {
|
var model = new CreateBlogViewModel {
|
||||||
Blog = _services.ContentManager.BuildEditorModel(blog)
|
Blog = Services.ContentManager.BuildEditorModel(blog)
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
@@ -58,25 +50,25 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Create(CreateBlogViewModel model) {
|
public ActionResult Create(CreateBlogViewModel model) {
|
||||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||||
if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
model.Blog = _services.ContentManager.UpdateEditorModel(_services.ContentManager.New<Blog>(BlogDriver.ContentType.Name), this);
|
model.Blog = Services.ContentManager.UpdateEditorModel(Services.ContentManager.New<Blog>(BlogDriver.ContentType.Name), this);
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return View(model);
|
return View(model);
|
||||||
|
|
||||||
_services.ContentManager.Create(model.Blog.Item.ContentItem);
|
Services.ContentManager.Create(model.Blog.Item.ContentItem);
|
||||||
|
|
||||||
//TEMP: (erikpo) ensure information has committed for this record
|
//TEMP: (erikpo) ensure information has committed for this record
|
||||||
_services.ContentManager.Flush();
|
Services.ContentManager.Flush();
|
||||||
|
|
||||||
return Redirect(Url.BlogForAdmin(model.Blog.Item.As<RoutableAspect>().Slug));
|
return Redirect(Url.BlogForAdmin(model.Blog.Item.As<RoutableAspect>().Slug));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Edit(string blogSlug) {
|
public ActionResult Edit(string blogSlug) {
|
||||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||||
if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
@@ -86,7 +78,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var model = new BlogEditViewModel {
|
var model = new BlogEditViewModel {
|
||||||
Blog = _services.ContentManager.BuildEditorModel(blog)
|
Blog = Services.ContentManager.BuildEditorModel(blog)
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
@@ -94,7 +86,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Edit(string blogSlug, FormCollection input) {
|
public ActionResult Edit(string blogSlug, FormCollection input) {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
@@ -104,7 +96,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var model = new BlogEditViewModel {
|
var model = new BlogEditViewModel {
|
||||||
Blog = _services.ContentManager.UpdateEditorModel(blog, this),
|
Blog = Services.ContentManager.UpdateEditorModel(blog, this),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
@@ -115,14 +107,14 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
CurrentSite.HomePage = "BlogHomePageProvider;" + model.Blog.Item.Id;
|
CurrentSite.HomePage = "BlogHomePageProvider;" + model.Blog.Item.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
_notifier.Information(T("Blog information updated"));
|
Services.Notifier.Information(T("Blog information updated"));
|
||||||
|
|
||||||
return Redirect(Url.BlogsForAdmin());
|
return Redirect(Url.BlogsForAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Delete(string blogSlug) {
|
public ActionResult Delete(string blogSlug) {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
@@ -133,7 +125,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
|
|
||||||
_blogService.Delete(blog);
|
_blogService.Delete(blog);
|
||||||
|
|
||||||
_notifier.Information(T("Blog was successfully deleted"));
|
Services.Notifier.Information(T("Blog was successfully deleted"));
|
||||||
|
|
||||||
return Redirect(Url.BlogsForAdmin());
|
return Redirect(Url.BlogsForAdmin());
|
||||||
}
|
}
|
||||||
@@ -142,7 +134,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||||
var model = new AdminBlogsViewModel {
|
var model = new AdminBlogsViewModel {
|
||||||
Entries = _blogService.Get()
|
Entries = _blogService.Get()
|
||||||
.Select(b => _services.ContentManager.BuildDisplayModel(b, "SummaryAdmin"))
|
.Select(b => Services.ContentManager.BuildDisplayModel(b, "SummaryAdmin"))
|
||||||
.Select(vm => new AdminBlogEntry { ContentItemViewModel = vm, TotalPostCount = _blogPostService.Get(vm.Item, VersionOptions.Latest).Count()})
|
.Select(vm => new AdminBlogEntry { ContentItemViewModel = vm, TotalPostCount = _blogPostService.Get(vm.Item, VersionOptions.Latest).Count()})
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,7 +150,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
|
|
||||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||||
var model = new BlogForAdminViewModel {
|
var model = new BlogForAdminViewModel {
|
||||||
Blog = _services.ContentManager.BuildDisplayModel(blog, "DetailAdmin")
|
Blog = Services.ContentManager.BuildDisplayModel(blog, "DetailAdmin")
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
|
@@ -7,7 +7,6 @@ using JetBrains.Annotations;
|
|||||||
using Orchard.Comments.Models;
|
using Orchard.Comments.Models;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.ContentManagement;
|
|
||||||
using Orchard.Services;
|
using Orchard.Services;
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
@@ -19,15 +18,10 @@ namespace Orchard.Comments.Controllers {
|
|||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly ICommentService _commentService;
|
private readonly ICommentService _commentService;
|
||||||
private readonly IAuthorizer _authorizer;
|
|
||||||
private readonly IClock _clock;
|
|
||||||
private readonly INotifier _notifier;
|
|
||||||
|
|
||||||
public AdminController(ICommentService commentService, IContentManager contentManager, INotifier notifier, IAuthorizer authorizer, IClock clock) {
|
public AdminController(IOrchardServices services, ICommentService commentService) {
|
||||||
_commentService = commentService;
|
_commentService = commentService;
|
||||||
_authorizer = authorizer;
|
Services = services;
|
||||||
_clock = clock;
|
|
||||||
_notifier = notifier;
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
@@ -35,6 +29,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||||
|
|
||||||
|
public IOrchardServices Services { get; set; }
|
||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
@@ -67,7 +62,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Listing comments failed: " + exception.Message));
|
Services.Notifier.Error(T("Listing comments failed: " + exception.Message));
|
||||||
return View(new CommentsIndexViewModel());
|
return View(new CommentsIndexViewModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +79,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
case CommentIndexBulkAction.None:
|
case CommentIndexBulkAction.None:
|
||||||
break;
|
break;
|
||||||
case CommentIndexBulkAction.MarkAsSpam:
|
case CommentIndexBulkAction.MarkAsSpam:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
//TODO: Transaction
|
//TODO: Transaction
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -92,7 +87,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommentIndexBulkAction.Pend:
|
case CommentIndexBulkAction.Pend:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
//TODO: Transaction
|
//TODO: Transaction
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -100,7 +95,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommentIndexBulkAction.Approve:
|
case CommentIndexBulkAction.Approve:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
//TODO: Transaction
|
//TODO: Transaction
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -108,7 +103,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommentIndexBulkAction.Delete:
|
case CommentIndexBulkAction.Delete:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -121,7 +116,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Editing comments failed: " + exception.Message));
|
Services.Notifier.Error(T("Editing comments failed: " + exception.Message));
|
||||||
return RedirectToAction("Index", "Admin", new { options = viewModel.Options });
|
return RedirectToAction("Index", "Admin", new { options = viewModel.Options });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +158,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Listing comments failed: " + exception.Message));
|
Services.Notifier.Error(T("Listing comments failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,7 +175,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
case CommentDetailsBulkAction.None:
|
case CommentDetailsBulkAction.None:
|
||||||
break;
|
break;
|
||||||
case CommentDetailsBulkAction.MarkAsSpam:
|
case CommentDetailsBulkAction.MarkAsSpam:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
//TODO: Transaction
|
//TODO: Transaction
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -188,7 +183,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommentDetailsBulkAction.Pend:
|
case CommentDetailsBulkAction.Pend:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -196,7 +191,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommentDetailsBulkAction.Approve:
|
case CommentDetailsBulkAction.Approve:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -204,7 +199,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommentDetailsBulkAction.Delete:
|
case CommentDetailsBulkAction.Delete:
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
foreach (CommentEntry entry in checkedEntries) {
|
foreach (CommentEntry entry in checkedEntries) {
|
||||||
@@ -217,7 +212,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Editing comments failed: " + exception.Message));
|
Services.Notifier.Error(T("Editing comments failed: " + exception.Message));
|
||||||
return Details(viewModel.CommentedItemId, viewModel.Options);
|
return Details(viewModel.CommentedItemId, viewModel.Options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +222,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Close(int commentedItemId, string returnUrl) {
|
public ActionResult Close(int commentedItemId, string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.CloseComment, T("Couldn't close comments")))
|
if (!Services.Authorizer.Authorize(Permissions.CloseComment, T("Couldn't close comments")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_commentService.CloseCommentsForCommentedContent(commentedItemId);
|
_commentService.CloseCommentsForCommentedContent(commentedItemId);
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
@@ -236,7 +231,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Closing Comments failed: " + exception.Message));
|
Services.Notifier.Error(T("Closing Comments failed: " + exception.Message));
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
@@ -247,7 +242,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Enable(int commentedItemId, string returnUrl) {
|
public ActionResult Enable(int commentedItemId, string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.EnableComment, T("Couldn't enable comments")))
|
if (!Services.Authorizer.Authorize(Permissions.EnableComment, T("Couldn't enable comments")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_commentService.EnableCommentsForCommentedContent(commentedItemId);
|
_commentService.EnableCommentsForCommentedContent(commentedItemId);
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
@@ -256,7 +251,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Enabling Comments failed: " + exception.Message));
|
Services.Notifier.Error(T("Enabling Comments failed: " + exception.Message));
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
@@ -279,7 +274,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Editing comment failed: " + exception.Message));
|
Services.Notifier.Error(T("Editing comment failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,14 +284,14 @@ namespace Orchard.Comments.Controllers {
|
|||||||
var viewModel = new CommentsEditViewModel();
|
var viewModel = new CommentsEditViewModel();
|
||||||
try {
|
try {
|
||||||
UpdateModel(viewModel);
|
UpdateModel(viewModel);
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't edit comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't edit comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
_commentService.UpdateComment(viewModel.Id, viewModel.Name, viewModel.Email, viewModel.SiteName, viewModel.CommentText, viewModel.Status);
|
_commentService.UpdateComment(viewModel.Id, viewModel.Name, viewModel.Email, viewModel.SiteName, viewModel.CommentText, viewModel.Status);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Editing Comment failed: " + exception.Message));
|
Services.Notifier.Error(T("Editing Comment failed: " + exception.Message));
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,7 +299,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Delete(int id, string returnUrl) {
|
public ActionResult Delete(int id, string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
int commentedOn = _commentService.GetComment(id).Record.CommentedOn;
|
int commentedOn = _commentService.GetComment(id).Record.CommentedOn;
|
||||||
@@ -316,7 +311,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
return RedirectToAction("Details", new { id = commentedOn });
|
return RedirectToAction("Details", new { id = commentedOn });
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Deleting comment failed: " + exception.Message));
|
Services.Notifier.Error(T("Deleting comment failed: " + exception.Message));
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
|
@@ -6,23 +6,19 @@ using Orchard.Localization;
|
|||||||
using Orchard.Media.Models;
|
using Orchard.Media.Models;
|
||||||
using Orchard.Media.Services;
|
using Orchard.Media.Services;
|
||||||
using Orchard.Media.ViewModels;
|
using Orchard.Media.ViewModels;
|
||||||
using Orchard.Security;
|
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.Media.Controllers {
|
namespace Orchard.Media.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly IMediaService _mediaService;
|
private readonly IMediaService _mediaService;
|
||||||
private readonly IAuthorizer _authorizer;
|
|
||||||
private readonly INotifier _notifier;
|
|
||||||
|
|
||||||
public AdminController(IMediaService mediaService, IAuthorizer authorizer, INotifier notifier) {
|
public AdminController(IOrchardServices services, IMediaService mediaService) {
|
||||||
|
Services = services;
|
||||||
_mediaService = mediaService;
|
_mediaService = mediaService;
|
||||||
_authorizer = authorizer;
|
|
||||||
_notifier = notifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IOrchardServices Services { get; set;}
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
@@ -44,7 +40,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Deleting Folder failed: " + exception.Message);
|
Services.Notifier.Error("Deleting Folder failed: " + exception.Message);
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,13 +54,13 @@ namespace Orchard.Media.Controllers {
|
|||||||
var viewModel = new MediaFolderCreateViewModel();
|
var viewModel = new MediaFolderCreateViewModel();
|
||||||
try {
|
try {
|
||||||
UpdateModel(viewModel);
|
UpdateModel(viewModel);
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't create media folder")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't create media folder")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_mediaService.CreateFolder(viewModel.MediaPath, viewModel.Name);
|
_mediaService.CreateFolder(viewModel.MediaPath, viewModel.Name);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Creating Folder failed: " + exception.Message);
|
Services.Notifier.Error("Creating Folder failed: " + exception.Message);
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,14 +79,14 @@ namespace Orchard.Media.Controllers {
|
|||||||
if (key.StartsWith("Checkbox.File.") && input[key] == "true") {
|
if (key.StartsWith("Checkbox.File.") && input[key] == "true") {
|
||||||
string fileName = key.Substring("Checkbox.File.".Length);
|
string fileName = key.Substring("Checkbox.File.".Length);
|
||||||
string folderName = input[fileName];
|
string folderName = input[fileName];
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_mediaService.DeleteFile(fileName, folderName);
|
_mediaService.DeleteFile(fileName, folderName);
|
||||||
}
|
}
|
||||||
else if (key.StartsWith("Checkbox.Folder.") && input[key] == "true") {
|
else if (key.StartsWith("Checkbox.Folder.") && input[key] == "true") {
|
||||||
string folderName = key.Substring("Checkbox.Folder.".Length);
|
string folderName = key.Substring("Checkbox.Folder.".Length);
|
||||||
string folderPath = input[folderName];
|
string folderPath = input[folderName];
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_mediaService.DeleteFolder(folderPath);
|
_mediaService.DeleteFolder(folderPath);
|
||||||
}
|
}
|
||||||
@@ -98,7 +94,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Deleting failed: " + exception.Message);
|
Services.Notifier.Error("Deleting failed: " + exception.Message);
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,13 +112,13 @@ namespace Orchard.Media.Controllers {
|
|||||||
//TODO: There may be better ways to do this.
|
//TODO: There may be better ways to do this.
|
||||||
// Delete
|
// Delete
|
||||||
if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) {
|
if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_mediaService.DeleteFolder(viewModel.MediaPath);
|
_mediaService.DeleteFolder(viewModel.MediaPath);
|
||||||
}
|
}
|
||||||
// Save
|
// Save
|
||||||
else {
|
else {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't rename media folder")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't rename media folder")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_mediaService.RenameFolder(viewModel.MediaPath, viewModel.Name);
|
_mediaService.RenameFolder(viewModel.MediaPath, viewModel.Name);
|
||||||
}
|
}
|
||||||
@@ -130,7 +126,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Modifying Folder Properties failed: " + exception.Message);
|
Services.Notifier.Error("Modifying Folder Properties failed: " + exception.Message);
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +141,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
var viewModel = new MediaItemAddViewModel();
|
var viewModel = new MediaItemAddViewModel();
|
||||||
try {
|
try {
|
||||||
UpdateModel(viewModel);
|
UpdateModel(viewModel);
|
||||||
if (!_authorizer.Authorize(Permissions.UploadMediaFiles, T("Couldn't upload media file")))
|
if (!Services.Authorizer.Authorize(Permissions.UploadMediaFiles, T("Couldn't upload media file")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
foreach (string fileName in Request.Files) {
|
foreach (string fileName in Request.Files) {
|
||||||
@@ -156,7 +152,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Uploading media file failed: " + exception.Message);
|
Services.Notifier.Error("Uploading media file failed: " + exception.Message);
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,11 +173,11 @@ namespace Orchard.Media.Controllers {
|
|||||||
var viewModel = new MediaItemEditViewModel();
|
var viewModel = new MediaItemEditViewModel();
|
||||||
try {
|
try {
|
||||||
UpdateModel(viewModel);
|
UpdateModel(viewModel);
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't modify media file")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't modify media file")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
// Delete
|
// Delete
|
||||||
if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) {
|
if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) {
|
||||||
if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file")))
|
if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
_mediaService.DeleteFile(viewModel.Name, viewModel.MediaPath);
|
_mediaService.DeleteFile(viewModel.Name, viewModel.MediaPath);
|
||||||
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
||||||
@@ -205,7 +201,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
mediaPath = viewModel.MediaPath });
|
mediaPath = viewModel.MediaPath });
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Editing media file failed: " + exception.Message);
|
Services.Notifier.Error("Editing media file failed: " + exception.Message);
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@ namespace Orchard.Roles.Controllers {
|
|||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
private readonly IRoleService _roleService;
|
private readonly IRoleService _roleService;
|
||||||
private readonly INotifier _notifier;
|
|
||||||
private readonly IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
|
||||||
public AdminController(
|
public AdminController(
|
||||||
@@ -26,7 +25,6 @@ namespace Orchard.Roles.Controllers {
|
|||||||
IAuthorizationService authorizationService) {
|
IAuthorizationService authorizationService) {
|
||||||
Services = services;
|
Services = services;
|
||||||
_roleService = roleService;
|
_roleService = roleService;
|
||||||
_notifier = notifier;
|
|
||||||
_authorizationService = authorizationService;
|
_authorizationService = authorizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +56,7 @@ namespace Orchard.Roles.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Deleting Role failed: " + exception.Message);
|
Services.Notifier.Error("Deleting Role failed: " + exception.Message);
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +88,7 @@ namespace Orchard.Roles.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Creating Role failed: " + exception.Message);
|
Services.Notifier.Error("Creating Role failed: " + exception.Message);
|
||||||
return RedirectToAction("Create");
|
return RedirectToAction("Create");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +142,7 @@ namespace Orchard.Roles.Controllers {
|
|||||||
return RedirectToAction("Edit", new { viewModel.Id });
|
return RedirectToAction("Edit", new { viewModel.Id });
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
_notifier.Error("Editing Role failed: " + exception.Message);
|
Services.Notifier.Error("Editing Role failed: " + exception.Message);
|
||||||
return RedirectToAction("Edit", viewModel.Id);
|
return RedirectToAction("Edit", viewModel.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@ using Orchard.Users.ViewModels;
|
|||||||
namespace Orchard.Users.Controllers {
|
namespace Orchard.Users.Controllers {
|
||||||
|
|
||||||
public class AdminController : Controller, IUpdateModel {
|
public class AdminController : Controller, IUpdateModel {
|
||||||
|
|
||||||
private readonly IMembershipService _membershipService;
|
private readonly IMembershipService _membershipService;
|
||||||
|
|
||||||
public AdminController(
|
public AdminController(
|
||||||
|
Reference in New Issue
Block a user