mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Minor refactoring to enable a localized string to be picked up by loc tool.
--HG-- branch : 1.x
This commit is contained in:
@@ -14,7 +14,6 @@ using Orchard.Mvc.Extensions;
|
|||||||
using Orchard.Themes.Services;
|
using Orchard.Themes.Services;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
using Orchard.Utility.Extensions;
|
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
using Orchard.Widgets.Services;
|
using Orchard.Widgets.Services;
|
||||||
|
|
||||||
@@ -23,8 +22,6 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
[ValidateInput(false), Admin]
|
[ValidateInput(false), Admin]
|
||||||
public class AdminController : Controller, IUpdateModel {
|
public class AdminController : Controller, IUpdateModel {
|
||||||
|
|
||||||
private const string NotAuthorizedManageWidgetsLabel = "Not authorized to manage widgets";
|
|
||||||
|
|
||||||
private readonly IWidgetsService _widgetsService;
|
private readonly IWidgetsService _widgetsService;
|
||||||
private readonly ISiteThemeService _siteThemeService;
|
private readonly ISiteThemeService _siteThemeService;
|
||||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
@@ -94,7 +91,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!string.IsNullOrWhiteSpace(moveOut))
|
if (!string.IsNullOrWhiteSpace(moveOut))
|
||||||
return DeleteWidget(widgetId, returnUrl);
|
return DeleteWidget(widgetId, returnUrl);
|
||||||
|
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(moveUp))
|
if (!string.IsNullOrWhiteSpace(moveUp))
|
||||||
@@ -107,9 +104,13 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsAuthorizedToManageWidgets() {
|
||||||
|
return Services.Authorizer.Authorize(Permissions.ManageWidgets, T("Not authorized to manage widgets"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ActionResult ChooseWidget(int layerId, string zone, string returnUrl) {
|
public ActionResult ChooseWidget(int layerId, string zone, string returnUrl) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(zone)) {
|
if (string.IsNullOrWhiteSpace(zone)) {
|
||||||
@@ -141,7 +142,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult AddWidget(int layerId, string widgetType, string zone, string returnUrl) {
|
public ActionResult AddWidget(int layerId, string widgetType, string zone, string returnUrl) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = Services.ContentManager.New<WidgetPart>(widgetType);
|
WidgetPart widgetPart = Services.ContentManager.New<WidgetPart>(widgetType);
|
||||||
@@ -165,7 +166,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
|
|
||||||
[HttpPost, ActionName("AddWidget")]
|
[HttpPost, ActionName("AddWidget")]
|
||||||
public ActionResult AddWidgetPOST(int layerId, string widgetType, string returnUrl) {
|
public ActionResult AddWidgetPOST(int layerId, string widgetType, string returnUrl) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", "", "");
|
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", "", "");
|
||||||
@@ -194,7 +195,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult AddLayer(string name, string description, string layerRule) { // <- hints for a new layer
|
public ActionResult AddLayer(string name, string description, string layerRule) { // <- hints for a new layer
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
LayerPart layerPart = Services.ContentManager.New<LayerPart>("Layer");
|
LayerPart layerPart = Services.ContentManager.New<LayerPart>("Layer");
|
||||||
@@ -217,7 +218,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
|
|
||||||
[HttpPost, ActionName("AddLayer")]
|
[HttpPost, ActionName("AddLayer")]
|
||||||
public ActionResult AddLayerPOST() {
|
public ActionResult AddLayerPOST() {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
LayerPart layerPart = _widgetsService.CreateLayer("", "", "");
|
LayerPart layerPart = _widgetsService.CreateLayer("", "", "");
|
||||||
@@ -237,7 +238,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult EditLayer(int id) {
|
public ActionResult EditLayer(int id) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
LayerPart layerPart = _widgetsService.GetLayer(id);
|
LayerPart layerPart = _widgetsService.GetLayer(id);
|
||||||
@@ -252,7 +253,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
[HttpPost, ActionName("EditLayer")]
|
[HttpPost, ActionName("EditLayer")]
|
||||||
[FormValueRequired("submit.Save")]
|
[FormValueRequired("submit.Save")]
|
||||||
public ActionResult EditLayerSavePOST(int id, string returnUrl) {
|
public ActionResult EditLayerSavePOST(int id, string returnUrl) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
LayerPart layerPart = _widgetsService.GetLayer(id);
|
LayerPart layerPart = _widgetsService.GetLayer(id);
|
||||||
@@ -275,7 +276,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
[HttpPost, ActionName("EditLayer")]
|
[HttpPost, ActionName("EditLayer")]
|
||||||
[FormValueRequired("submit.Delete")]
|
[FormValueRequired("submit.Delete")]
|
||||||
public ActionResult EditLayerDeletePOST(int id) {
|
public ActionResult EditLayerDeletePOST(int id) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -290,7 +291,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult EditWidget(int id) {
|
public ActionResult EditWidget(int id) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = null;
|
WidgetPart widgetPart = null;
|
||||||
@@ -318,7 +319,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
[HttpPost, ActionName("EditWidget")]
|
[HttpPost, ActionName("EditWidget")]
|
||||||
[FormValueRequired("submit.Save")]
|
[FormValueRequired("submit.Save")]
|
||||||
public ActionResult EditWidgetSavePOST(int id, int layerId, string returnUrl) {
|
public ActionResult EditWidgetSavePOST(int id, int layerId, string returnUrl) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = null;
|
WidgetPart widgetPart = null;
|
||||||
@@ -350,7 +351,7 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return DeleteWidget(id, returnUrl);
|
return DeleteWidget(id, returnUrl);
|
||||||
}
|
}
|
||||||
private ActionResult DeleteWidget(int id, string returnUrl) {
|
private ActionResult DeleteWidget(int id, string returnUrl) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!IsAuthorizedToManageWidgets())
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = null;
|
WidgetPart widgetPart = null;
|
||||||
|
Reference in New Issue
Block a user