public ActionResult Configure(ConfigurationModel model, FormCollection form)
		{
			if (!ModelState.IsValid)
				return Configure();

			ModelState.Clear();

			var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
			int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext);
			var settings = _services.Settings.LoadSetting<AmazonPaySettings>(storeScope);

			model.Copy(settings, false);

			storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings);

			_services.Settings.SaveSetting(settings, x => x.DataFetching, 0, false);
			_services.Settings.SaveSetting(settings, x => x.PollingMaxOrderCreationDays, 0, false);

			_apiService.DataPollingTaskUpdate(settings.DataFetching == AmazonPayDataFetchingType.Polling, model.PollingTaskMinutes * 60);

			_services.Settings.ClearCache();
			NotifySuccess(_services.Localization.GetResource("Plugins.Payments.AmazonPay.ConfigSaveNote"));

			return Configure();
		}
Ejemplo n.º 2
0
        public ActionResult Configure(ProfilerSettings model, FormCollection form)
        {
            if (!ModelState.IsValid)
                return Configure();

            ModelState.Clear();

            // load settings for a chosen store scope
            var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);

            storeDependingSettingHelper.UpdateSettings(model /*settings*/, form, storeScope, _settingService);
            _settingService.ClearCache();

            return Configure();
        }
        public ActionResult Configure(ConfigurationModel model, FormCollection form)
        {
			//load settings for a chosen store scope
			var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
			var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsSettings>(storeScope);
            googleAnalyticsSettings.GoogleId = model.GoogleId;
            googleAnalyticsSettings.TrackingScript = model.TrackingScript; 
            googleAnalyticsSettings.EcommerceScript = model.EcommerceScript;
            googleAnalyticsSettings.EcommerceDetailScript = model.EcommerceDetailScript;
            googleAnalyticsSettings.WidgetZone = model.ZoneId;

			_settingService.SaveSetting(googleAnalyticsSettings, x => x.WidgetZone, 0, false);

			var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
			storeDependingSettingHelper.UpdateSettings(googleAnalyticsSettings, form, storeScope, _settingService);

			//now clear settings cache
			_settingService.ClearCache();

            return Configure();
        }
        public ActionResult Configure(ConfigurationModel model, FormCollection form)
        {
            if (!HasPermission(false))
                return Configure();

            if (!ModelState.IsValid)
                return Configure();

            var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
            int storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext);
            var settings = _services.Settings.LoadSetting<FacebookExternalAuthSettings>(storeScope);

            settings.ClientKeyIdentifier = model.ClientKeyIdentifier;
            settings.ClientSecret = model.ClientSecret;

            storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings);
            _services.Settings.ClearCache();

            NotifySuccess(_services.Localization.GetResource("Admin.Common.DataSuccessfullySaved"));

            return Configure();
        }
Ejemplo n.º 5
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (filterContext.Controller.ViewData.ModelState.IsValid)
            {
                var updateSettings = true;
                var redirectResult = filterContext.Result as RedirectToRouteResult;
                if (redirectResult != null)
                {
                    var controllerName = redirectResult.RouteValues["controller"] as string;
                    var areaName       = redirectResult.RouteValues["area"] as string;
                    if (controllerName.IsCaseInsensitiveEqual("security") && areaName.IsCaseInsensitiveEqual("admin"))
                    {
                        // Insufficient permission. We must not save because the action did not run.
                        updateSettings = false;
                    }
                }

                if (updateSettings)
                {
                    var settingHelper = new StoreDependingSettingHelper(filterContext.Controller.ViewData);

                    foreach (var param in _settingParams)
                    {
                        settingHelper.UpdateSettings(param.Instance, _form, _storeId, Services.Settings);
                    }
                }
            }

            if (_settingsWriteBatch != null)
            {
                _settingsWriteBatch.Dispose();
                _settingsWriteBatch = null;
            }

            base.OnActionExecuted(filterContext);
        }
        public ActionResult Configure(PayPalExpressConfigurationModel model, FormCollection form)
        {
            if (!ModelState.IsValid)
                return Configure();

            ModelState.Clear();

            var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
            int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext);
            var settings = _services.Settings.LoadSetting<PayPalExpressPaymentSettings>(storeScope);

            model.Copy(settings, false);

            storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings);

            // multistore context not possible, see IPN handling
            _services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false);

            _services.Settings.ClearCache();
            NotifySuccess(_services.Localization.GetResource("Plugins.Payments.PayPal.ConfigSaveNote"));

            return Configure();
        }
		public ActionResult Configure(ConfigurationModel model, FormCollection form)
        {
            if (!ModelState.IsValid)
                return Configure();

			//load settings for a chosen store scope
			var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
			var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
			var trustedShopsSealSettings = _settingService.LoadSetting<TrustedShopsSealSettings>(storeScope);

			bool trustedShopIdOverride = storeDependingSettingHelper.IsOverrideChecked(trustedShopsSealSettings, "TrustedShopsId", form);
			bool isTrustedShopIdValid = true;

			if (trustedShopIdOverride || storeScope == 0)	// do validation
			{
				isTrustedShopIdValid = IsTrustedShopIdValid(model);

				if (isTrustedShopIdValid)
					NotifySuccess(_localizationService.GetResource("Plugins.Widgets.TrustedShopsSeal.CheckIdSuccess"), true);
				else
					NotifyError(_localizationService.GetResource("Plugins.Widgets.TrustedShopsSeal.CheckIdError"), true);
			}

			if (isTrustedShopIdValid)	//save settings
			{
				trustedShopsSealSettings.TrustedShopsId = model.TrustedShopsId;
				trustedShopsSealSettings.IsTestMode = model.IsTestMode;
				trustedShopsSealSettings.WidgetZone = model.WidgetZone;
				trustedShopsSealSettings.ShopName = model.ShopName;
				trustedShopsSealSettings.ShopText = model.ShopText;

				storeDependingSettingHelper.UpdateSettings(trustedShopsSealSettings, form, storeScope, _settingService);
				_settingService.ClearCache();
			}

            return Configure();
        }