From 69f963e820b19678aa54fbdae05e098d6ebbcdc2 Mon Sep 17 00:00:00 2001 From: Romulo AC Date: Thu, 29 Aug 2019 01:50:30 -0300 Subject: [PATCH] =?UTF-8?q?Migra=C3=A7=C3=A3o=20para=20vers=C3=A3o=204.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BlogPlugin.cs | 4 +++- Controllers/WidgetsBlogController.cs | 22 ++++++++++++++++++---- NopBrasil.Plugin.Widgets.Blog.csproj | 15 +++++++++------ plugin.json | 2 +- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/BlogPlugin.cs b/BlogPlugin.cs index c061e44..ecdc0a6 100644 --- a/BlogPlugin.cs +++ b/BlogPlugin.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using Nop.Core; -using Nop.Core.Plugins; +using Nop.Services.Plugins; using Nop.Services.Cms; using Nop.Services.Configuration; using Nop.Services.Localization; @@ -56,5 +56,7 @@ public override void Uninstall() } public string GetWidgetViewComponentName(string widgetZone) => "WidgetsBlog"; + + public bool HideInWidgetList => false; } } \ No newline at end of file diff --git a/Controllers/WidgetsBlogController.cs b/Controllers/WidgetsBlogController.cs index 4f42bf5..78b639b 100644 --- a/Controllers/WidgetsBlogController.cs +++ b/Controllers/WidgetsBlogController.cs @@ -4,26 +4,37 @@ using Nop.Web.Framework; using Microsoft.AspNetCore.Mvc; using Nop.Services.Localization; +using Nop.Services.Security; +using Nop.Services.Messages; +using Nop.Web.Framework.Mvc.Filters; namespace NopBrasil.Plugin.Widgets.Blog.Controllers { + [AuthorizeAdmin] [Area(AreaNames.Admin)] public class WidgetsBlogController : BasePluginController { private readonly ISettingService _settingService; private readonly ILocalizationService _localizationService; private readonly BlogSettings _BlogSettings; + private readonly INotificationService _notificationService; + private readonly IPermissionService _permissionService; public WidgetsBlogController(ISettingService settingService, ILocalizationService localizationService, - BlogSettings BlogSettings) + BlogSettings BlogSettings, INotificationService notificationService, IPermissionService permissionService) { this._settingService = settingService; this._localizationService = localizationService; this._BlogSettings = BlogSettings; + this._notificationService = notificationService; + this._permissionService = permissionService; } - public ActionResult Configure() + public IActionResult Configure() { + if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) + return AccessDeniedView(); + var model = new ConfigurationModel() { WidgetZone = _BlogSettings.WidgetZone, @@ -33,15 +44,18 @@ public ActionResult Configure() } [HttpPost] - public ActionResult Configure(ConfigurationModel model) + public IActionResult Configure(ConfigurationModel model) { + if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) + return AccessDeniedView(); + if (!ModelState.IsValid) return Configure(); _BlogSettings.QtdBlogPosts = model.QtdBlogPosts; _BlogSettings.WidgetZone = model.WidgetZone; _settingService.SaveSetting(_BlogSettings); - SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); + _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return Configure(); } } diff --git a/NopBrasil.Plugin.Widgets.Blog.csproj b/NopBrasil.Plugin.Widgets.Blog.csproj index aa10304..7f44a4d 100644 --- a/NopBrasil.Plugin.Widgets.Blog.csproj +++ b/NopBrasil.Plugin.Widgets.Blog.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1 + netcoreapp2.2 Copyright © nopCommerce Brasil nopCommerce Brasil nopCommerce Brasil - www.nopcommercebrasil.com - nopcommercebrasil@nopcommercebrasil.com @@ -12,17 +12,17 @@ Git - ..\nopCommerce410\Presentation\Nop.Web\Plugins\Widgets.Blog\ + ..\nopCommerce420\src\Presentation\Nop.Web\Plugins\Widgets.Blog\ $(OutputPath) - ..\nopCommerce410\Presentation\Nop.Web\Plugins\Widgets.Blog\ + ..\nopCommerce420\src\Presentation\Nop.Web\Plugins\Widgets.Blog\ $(OutputPath) - + @@ -51,9 +51,12 @@ Always + + + - - + + \ No newline at end of file diff --git a/plugin.json b/plugin.json index 6c09915..408c0ae 100644 --- a/plugin.json +++ b/plugin.json @@ -3,7 +3,7 @@ "FriendlyName": "Blog", "SystemName": "Widgets.Blog", "Version": "1.00", - "SupportedVersions": [ "4.10" ], + "SupportedVersions": [ "4.20" ], "Author": "nopCommerce Brasil - www.nopcommercebrasil.com - nopcommercebrasil@nopcommercebrasil.com", "DisplayOrder": 1, "FileName": "NopBrasil.Plugin.Widgets.Blog.dll",