public IActionResult GeneralCommon(GeneralCommonSettingsModel model) { StoreInformationSettings store = _settingService.LoadSetting <StoreInformationSettings>(); store.StoreClosed = model.StoreInformationSettings.StoreClosed; store.LogoPictureId = model.StoreInformationSettings.LogoPictureId; store.HeaderBannerPictureId = model.StoreInformationSettings.HeaderBannerPictureId; store.WhiteLogoPictureId = model.StoreInformationSettings.WhiteLogoPictureId; //social pages store.FacebookLink = model.StoreInformationSettings.FacebookLink; store.TwitterLink = model.StoreInformationSettings.TwitterLink; store.YoutubeLink = model.StoreInformationSettings.YoutubeLink; store.GooglePlusLink = model.StoreInformationSettings.GooglePlusLink; store.InstagramLink = model.StoreInformationSettings.InstagramLink; store.MaximumImageSize = model.StoreInformationSettings.MaximumImageSize; store.MultipleThumbDirectories = model.StoreInformationSettings.MultipleThumbDirectories; store.PopupGridPageSize = model.StoreInformationSettings.PopupGridPageSize; store.RichEditorAdditionalSettings = model.StoreInformationSettings.RichEditorAdditionalSettings; store.RichEditorAllowStyleTag = model.StoreInformationSettings.RichEditorAllowStyleTag; store.RichEditorAllowJavaScript = model.StoreInformationSettings.RichEditorAllowJavaScript; store.UseIsoDateFormatInJsonResult = model.StoreInformationSettings.UseIsoDateFormatInJsonResult; store.UseNestedSetting = model.StoreInformationSettings.UseNestedSetting; store.AvatarPictureSize = model.StoreInformationSettings.AvatarPictureSize; store.ContactEmail = model.StoreInformationSettings.ContactEmail; store.DefaultGridPageSize = model.StoreInformationSettings.DefaultGridPageSize; store.DefaultImageQuality = model.StoreInformationSettings.DefaultImageQuality; store.DisplayMiniProfilerForAdminOnly = model.StoreInformationSettings.DisplayMiniProfilerForAdminOnly; store.CopyRigth = model.StoreInformationSettings.CopyRigth; _settingService.SaveSetting <StoreInformationSettings>(store, 0); SuccessNotification("Ayarlar Güncellendi"); return(RedirectToAction("GeneralCommon")); }
public virtual IActionResult GeneralCommon() { //prepare model GeneralCommonSettingsModel model = _settingModelFactory.PrepareGeneralCommonSettingsModel(); return(View(model)); }
/// <summary> /// Prepare general and common settings model /// </summary> /// <returns>General and common settings model</returns> public virtual GeneralCommonSettingsModel PrepareGeneralCommonSettingsModel() { var model = new GeneralCommonSettingsModel(); //prepare SEO settings model model.SeoSettings = PrepareSeoSettingsModel(); //prepare security settings model model.SecuritySettings = PrepareSecuritySettingsModel(); //prepare captcha settings model model.CaptchaSettings = PrepareCaptchaSettingsModel(); //prepare PDF settings model model.PdfSettings = PreparePdfSettingsModel(); //prepare PDF settings model model.LocalizationSettings = PrepareLocalizationSettingsModel(); //prepare full-text settings model model.FullTextSettings = PrepareFullTextSettingsModel(); //prepare admin area settings model model.AdminAreaSettings = PrepareAdminAreaSettingsModel(); //prepare display default menu item settings model model.DisplayDefaultMenuItemSettings = PrepareDisplayDefaultMenuItemSettingsModel(); //prepare display default footer item settings model model.DisplayDefaultFooterItemSettings = PrepareDisplayDefaultFooterItemSettingsModel(); return(model); }
public virtual IActionResult ChangeEncryptionKey(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } try { if (model.SecuritySettings.EncryptionKey == null) { model.SecuritySettings.EncryptionKey = string.Empty; } model.SecuritySettings.EncryptionKey = model.SecuritySettings.EncryptionKey.Trim(); var newEncryptionPrivateKey = model.SecuritySettings.EncryptionKey; if (string.IsNullOrEmpty(newEncryptionPrivateKey) || newEncryptionPrivateKey.Length != 16) { throw new NopException(_localizationService.GetResource("Admin.Configuration.Settings.GeneralCommon.EncryptionKey.TooShort")); } SuccessNotification(_localizationService.GetResource("Admin.Configuration.Settings.GeneralCommon.EncryptionKey.Changed")); } catch (Exception exc) { ErrorNotification(exc); } return(RedirectToAction("GeneralCommon")); }
/// <summary> /// Prepare general and common settings model /// </summary> /// <returns>General and common settings model</returns> public virtual GeneralCommonSettingsModel PrepareGeneralCommonSettingsModel() { GeneralCommonSettingsModel model = new GeneralCommonSettingsModel(); //prepare store information settings model model.StoreInformationSettings = PrepareStoreInformationSettingsModel(); return(model); }
public virtual IActionResult ToggleFullText(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } return(RedirectToAction("GeneralCommon")); }
public async Task <IActionResult> ChangeEncryptionKey(GeneralCommonSettingsModel model) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } var tenantScope = _tenantContext.ActiveTenantScopeConfiguration; var securitySettings = _settingService.LoadSetting <SecuritySettings>(tenantScope); try { if (model.SecuritySettings.EncryptionKey == null) { model.SecuritySettings.EncryptionKey = string.Empty; } model.SecuritySettings.EncryptionKey = model.SecuritySettings.EncryptionKey.Trim(); var newEncryptionPrivateKey = model.SecuritySettings.EncryptionKey; if (string.IsNullOrEmpty(newEncryptionPrivateKey) || newEncryptionPrivateKey.Length != 16) { throw new DefaultException("Encryption private key must be 16 characters long."); } var oldEncryptionPrivateKey = securitySettings.EncryptionKey; if (oldEncryptionPrivateKey == newEncryptionPrivateKey) { throw new DefaultException("The new encryption key is the same as the old one."); } //update password information var userPasswords = _userService.GetUserPasswords(passwordFormat: PasswordFormat.Encrypted); foreach (var userPassword in userPasswords) { var decryptedPassword = _encryptionService.DecryptText(userPassword.Password, oldEncryptionPrivateKey); var encryptedPassword = _encryptionService.EncryptText(decryptedPassword, newEncryptionPrivateKey); userPassword.Password = encryptedPassword; _userService.UpdateUserPassword(userPassword); } securitySettings.EncryptionKey = newEncryptionPrivateKey; _settingService.SaveSetting(securitySettings); _notificationService.SuccessNotification("Encryption key changed"); } catch (Exception ex) { _notificationService.ErrorNotification(ex); } return(RedirectToAction("GeneralCommon")); }
public virtual ActionResult ChangeEncryptionKey(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } this.Server.ScriptTimeout = 300; var securitySettings = _settingService.LoadSetting <SecuritySettings>(); try { if (model.SecuritySettings.EncryptionKey == null) { model.SecuritySettings.EncryptionKey = ""; } model.SecuritySettings.EncryptionKey = model.SecuritySettings.EncryptionKey.Trim(); var newEncryptionPrivateKey = model.SecuritySettings.EncryptionKey; if (string.IsNullOrEmpty(newEncryptionPrivateKey) || newEncryptionPrivateKey.Length != 16) { throw new SiteException(_localizationService.GetResource("Admin.Configuration.Settings.GeneralCommon.EncryptionKey.TooShort")); } string oldEncryptionPrivateKey = securitySettings.EncryptionKey; if (oldEncryptionPrivateKey == newEncryptionPrivateKey) { throw new SiteException(_localizationService.GetResource("Admin.Configuration.Settings.GeneralCommon.EncryptionKey.TheSame")); } //更改所有该加密格式的用户密码密钥 var customerPasswords = _customerService.GetCustomerPasswords(passwordFormat: PasswordFormat.Encrypted); foreach (var customerPassword in customerPasswords) { var decryptedPassword = _encryptionService.DecryptText(customerPassword.Password, oldEncryptionPrivateKey); var encryptedPassword = _encryptionService.EncryptText(decryptedPassword, newEncryptionPrivateKey); customerPassword.Password = encryptedPassword; _customerService.UpdateCustomerPassword(customerPassword); } securitySettings.EncryptionKey = newEncryptionPrivateKey; _settingService.SaveSetting(securitySettings); SuccessNotification(_localizationService.GetResource("Admin.Configuration.Settings.GeneralCommon.EncryptionKey.Changed")); } catch (Exception e) { ErrorNotification(e); } return(RedirectToAction("GeneralCommon")); }
public async Task <IActionResult> GeneralCommon(GeneralCommonSettingsModel model) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } var tenantScope = _tenantContext.ActiveTenantScopeConfiguration; //common settings var commonSettings = _settingService.LoadSetting <CommonSettings>(tenantScope); commonSettings.LogoPictureId = model.CommonSettings.LogoPictureId; commonSettings.UseResponseCompression = model.CommonSettings.UseResponseCompression; await _settingService.SaveSettingOverridablePerTenant(commonSettings, x => x.LogoPictureId, model.CommonSettings.LogoPictureId_OverrideForTenant, tenantScope, false); await _settingService.SaveSettingOverridablePerTenant(commonSettings, x => x.UseResponseCompression, model.CommonSettings.UseResponseCompression_OverrideForTenant, tenantScope, false); _settingService.ClearCache(); //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(tenantScope); if (securitySettings.AllowedIpAddresses == null) { securitySettings.AllowedIpAddresses = new List <string>(); } securitySettings.AllowedIpAddresses.Clear(); if (!string.IsNullOrEmpty(model.SecuritySettings.AllowedIpAddresses)) { foreach (var s in model.SecuritySettings.AllowedIpAddresses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrWhiteSpace(s)) { securitySettings.AllowedIpAddresses.Add(s.Trim()); } } } securitySettings.ForceSslForAllPages = model.SecuritySettings.ForceSslForAllPages; securitySettings.EnableXsrfProtection = model.SecuritySettings.EnableXsrfProtection; _settingService.SaveSetting(securitySettings); await _userActivityService.InsertActivityAsync("EditSettings", "Edited settings"); _notificationService.SuccessNotification("The settings have been updated successfully."); return(RedirectToAction("GeneralCommon")); }
public ActionResult ToggleFullText(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } var commonSettings = _settingService.LoadSetting <CommonSettings>(); try { if (!_fulltextService.IsFullTextSupported()) { throw new NopException( _localizationService.GetResource( "Admin.Configuration.Settings.GeneralCommon.FullTextSettings.NotSupported")); } if (commonSettings.UseFullTextSearch) { _fulltextService.DisableFullText(); commonSettings.UseFullTextSearch = false; _settingService.SaveSetting(commonSettings); SuccessNotification( _localizationService.GetResource( "Admin.Configuration.Settings.GeneralCommon.FullTextSettings.Disabled")); } else { _fulltextService.EnableFullText(); commonSettings.UseFullTextSearch = true; _settingService.SaveSetting(commonSettings); SuccessNotification( _localizationService.GetResource( "Admin.Configuration.Settings.GeneralCommon.FullTextSettings.Enabled")); } } catch (Exception exc) { ErrorNotification(exc); } //selected tab SaveSelectedTabIndex(); return(RedirectToAction("GeneralCommon")); }
public async Task <GeneralCommonSettingsModel> PrepareGeneralCommonSettingsModel() { var model = new GeneralCommonSettingsModel { ActiveTenantScopeConfiguration = _tenantContext.ActiveTenantScopeConfiguration, //prepare common settings model CommonSettings = await PrepareCommonSettingsModel(), //prepare security settings model SecuritySettings = await PrepareSecuritySettingsModel(), }; return(model); }
//[LoadSetting(IsRootedModel = true)] public ActionResult GeneralCommon(int storeScope, StoreInformationSettings storeInformationSettings, SeoSettings seoSettings, DateTimeSettings dateTimeSettings, SecuritySettings securitySettings, CaptchaSettings captchaSettings, PdfSettings pdfSettings, LocalizationSettings localizationSettings, CompanyInformationSettings companySettings, ContactDataSettings contactDataSettings, BankConnectionSettings bankConnectionSettings, SocialSettings socialSettings, HomePageSettings homePageSettings) { // TODO: (mh) (core) // Set page timeout to 5 minutes. //Server.ScriptTimeout = 300; var model = new GeneralCommonSettingsModel(); return(View(model)); }
public ActionResult GeneralCommon() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } //set page timeout to 5 minutes Server.ScriptTimeout = 300; var model = new GeneralCommonSettingsModel(); //store information var storeInformationSettings = _settingService.LoadSetting <StoreInformationSettings>(); var commonSettings = _settingService.LoadSetting <CommonSettings>(); model.StoreInformationSettings.StoreClosed = storeInformationSettings.StoreClosed; model.StoreInformationSettings.Name = storeInformationSettings.Name; model.StoreInformationSettings.Url = storeInformationSettings.Url; model.StoreInformationSettings.Hosts = storeInformationSettings.Hosts; model.StoreInformationSettings.DefaultLanguageId = storeInformationSettings.DefaultLanguageId; //social setting var socialSettings = _settingService.LoadSetting <SocialSettings>(); model.SocialSettings.FacebookAppId = socialSettings.FacebookAppId; model.SocialSettings.FacebookAppSecret = socialSettings.FacebookAppSecret; //themes model.StoreInformationSettings.DefaultStoreTheme = storeInformationSettings.DefaultStoreTheme; model.StoreInformationSettings.AvailableStoreThemes = _themeProvider .GetThemeConfigurations() .Select(x => new GeneralCommonSettingsModel.StoreInformationSettingsModel.ThemeConfigurationModel { ThemeTitle = x.ThemeTitle, ThemeName = x.ThemeName, PreviewImageUrl = x.PreviewImageUrl, PreviewText = x.PreviewText, SupportRtl = x.SupportRtl, Selected = x.ThemeName.Equals(storeInformationSettings.DefaultStoreTheme, StringComparison.InvariantCultureIgnoreCase) }) .ToList(); model.StoreInformationSettings.AllowCustomerToSelectTheme = storeInformationSettings.AllowCustomerToSelectTheme; //EU Cookie law model.StoreInformationSettings.DisplayEuCookieLawWarning = storeInformationSettings.DisplayEuCookieLawWarning; //social pages model.StoreInformationSettings.FacebookLink = storeInformationSettings.FacebookLink; model.StoreInformationSettings.TwitterLink = storeInformationSettings.TwitterLink; model.StoreInformationSettings.YoutubeLink = storeInformationSettings.YoutubeLink; model.StoreInformationSettings.GooglePlusLink = storeInformationSettings.GooglePlusLink; //contact us model.StoreInformationSettings.SubjectFieldOnContactUsForm = commonSettings.SubjectFieldOnContactUsForm; model.StoreInformationSettings.UseSystemEmailForContactUsForm = commonSettings.UseSystemEmailForContactUsForm; //seo settings var seoSettings = _settingService.LoadSetting <SeoSettings>(); model.SeoSettings.PageTitleSeparator = seoSettings.PageTitleSeparator; model.SeoSettings.PageTitleSeoAdjustment = (int)seoSettings.PageTitleSeoAdjustment; model.SeoSettings.PageTitleSeoAdjustmentValues = seoSettings.PageTitleSeoAdjustment.ToSelectList(); model.SeoSettings.DefaultTitle = seoSettings.DefaultTitle; model.SeoSettings.DefaultMetaKeywords = seoSettings.DefaultMetaKeywords; model.SeoSettings.DefaultMetaDescription = seoSettings.DefaultMetaDescription; model.SeoSettings.GeneratePostMetaDescription = seoSettings.GeneratePostMetaDescription; model.SeoSettings.ConvertNonWesternChars = seoSettings.ConvertNonWesternChars; model.SeoSettings.CanonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled; model.SeoSettings.WwwRequirement = (int)seoSettings.WwwRequirement; model.SeoSettings.WwwRequirementValues = seoSettings.WwwRequirement.ToSelectList(); model.SeoSettings.EnableJsBundling = seoSettings.EnableJsBundling; model.SeoSettings.EnableCssBundling = seoSettings.EnableCssBundling; model.SeoSettings.TwitterMetaTags = seoSettings.TwitterMetaTags; model.SeoSettings.OpenGraphMetaTags = seoSettings.OpenGraphMetaTags; //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(); var captchaSettings = _settingService.LoadSetting <CaptchaSettings>(); model.SecuritySettings.EncryptionKey = securitySettings.EncryptionKey; if (securitySettings.AdminAreaAllowedIpAddresses != null) { for (var i = 0; i < securitySettings.AdminAreaAllowedIpAddresses.Count; i++) { model.SecuritySettings.AdminAreaAllowedIpAddresses += securitySettings.AdminAreaAllowedIpAddresses[i]; if (i != securitySettings.AdminAreaAllowedIpAddresses.Count - 1) { model.SecuritySettings.AdminAreaAllowedIpAddresses += ","; } } } model.SecuritySettings.ForceSslForAllPages = securitySettings.ForceSslForAllPages; model.SecuritySettings.EnableXsrfProtectionForAdminArea = securitySettings.EnableXsrfProtectionForAdminArea; model.SecuritySettings.EnableXsrfProtectionForPublicStore = securitySettings.EnableXsrfProtectionForPublicStore; model.SecuritySettings.HoneypotEnabled = securitySettings.HoneypotEnabled; model.SecuritySettings.CaptchaEnabled = captchaSettings.Enabled; model.SecuritySettings.CaptchaShowOnLoginPage = captchaSettings.ShowOnLoginPage; model.SecuritySettings.CaptchaShowOnRegistrationPage = captchaSettings.ShowOnRegistrationPage; model.SecuritySettings.CaptchaShowOnContactUsPage = captchaSettings.ShowOnContactUsPage; model.SecuritySettings.CaptchaShowOnEmailWishlistToFriendPage = captchaSettings.ShowOnEmailWishlistToFriendPage; model.SecuritySettings.CaptchaShowOnEmailPostToFriendPage = captchaSettings.ShowOnEmailPostToFriendPage; model.SecuritySettings.CaptchaShowOnBlogCommentPage = captchaSettings.ShowOnBlogCommentPage; model.SecuritySettings.CaptchaShowOnNewsCommentPage = captchaSettings.ShowOnNewsCommentPage; model.SecuritySettings.CaptchaShowOnPostReviewPage = captchaSettings.ShowOnPostReviewPage; model.SecuritySettings.CaptchaShowOnApplyVendorPage = captchaSettings.ShowOnApplyVendorPage; model.SecuritySettings.ReCaptchaPublicKey = captchaSettings.ReCaptchaPublicKey; model.SecuritySettings.ReCaptchaPrivateKey = captchaSettings.ReCaptchaPrivateKey; //localization var localizationSettings = _settingService.LoadSetting <LocalizationSettings>(); model.LocalizationSettings.UseImagesForLanguageSelection = localizationSettings.UseImagesForLanguageSelection; model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled = localizationSettings.SeoFriendlyUrlsForLanguagesEnabled; model.LocalizationSettings.AutomaticallyDetectLanguage = localizationSettings.AutomaticallyDetectLanguage; model.LocalizationSettings.LoadAllLocaleRecordsOnStartup = localizationSettings.LoadAllLocaleRecordsOnStartup; model.LocalizationSettings.LoadAllLocalizedPropertiesOnStartup = localizationSettings.LoadAllLocalizedPropertiesOnStartup; model.LocalizationSettings.LoadAllUrlRecordsOnStartup = localizationSettings.LoadAllUrlRecordsOnStartup; //full-text support model.FullTextSettings.Supported = _fulltextService.IsFullTextSupported(); model.FullTextSettings.Enabled = commonSettings.UseFullTextSearch; model.FullTextSettings.SearchMode = (int)commonSettings.FullTextMode; model.FullTextSettings.SearchModeValues = commonSettings.FullTextMode.ToSelectList(); return(View(model)); }
public async Task <IActionResult> GeneralCommon( GeneralCommonSettingsModel model, int storeScope, StoreInformationSettings storeInformationSettings, SeoSettings seoSettings, DateTimeSettings dateTimeSettings, SecuritySettings securitySettings, CaptchaSettings captchaSettings, PdfSettings pdfSettings, LocalizationSettings localizationSettings, CompanyInformationSettings companySettings, ContactDataSettings contactDataSettings, BankConnectionSettings bankConnectionSettings, SocialSettings socialSettings, HomePageSettings homePageSeoSettings) { if (!ModelState.IsValid) { await PrepareConfigurationModelAsync(model); return(View(model)); } ModelState.Clear(); // Necessary before mapping var resetUserSeoCharacterTable = seoSettings.SeoNameCharConversion != model.SeoSettings.SeoNameCharConversion; var clearSeoFriendlyUrls = localizationSettings.SeoFriendlyUrlsForLanguagesEnabled != model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled; var prevPdfLogoId = pdfSettings.LogoPictureId; // Map model to entities MiniMapper.Map(model.StoreInformationSettings, storeInformationSettings); MiniMapper.Map(model.SeoSettings, seoSettings); MiniMapper.Map(model.DateTimeSettings, dateTimeSettings); MiniMapper.Map(model.SecuritySettings, securitySettings); MiniMapper.Map(model.CaptchaSettings, captchaSettings); MiniMapper.Map(model.PdfSettings, pdfSettings); MiniMapper.Map(model.LocalizationSettings, localizationSettings); MiniMapper.Map(model.CompanyInformationSettings, companySettings); MiniMapper.Map(model.ContactDataSettings, contactDataSettings); MiniMapper.Map(model.BankConnectionSettings, bankConnectionSettings); MiniMapper.Map(model.SocialSettings, socialSettings); MiniMapper.Map(model.HomepageSettings, homePageSeoSettings); #region POST mapping // Set CountryId explicitly else it can't be resetted. companySettings.CountryId = model.CompanyInformationSettings.CountryId ?? 0; //// (Un)track PDF logo id await _mediaTracker.Value.TrackAsync(pdfSettings, prevPdfLogoId, x => x.LogoPictureId); seoSettings.MetaTitle = model.SeoSettings.MetaTitle; seoSettings.MetaDescription = model.SeoSettings.MetaDescription; seoSettings.MetaKeywords = model.SeoSettings.MetaKeywords; foreach (var localized in model.SeoSettings.Locales) { await _localizedEntityService.ApplyLocalizedSettingAsync(seoSettings, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId, storeScope); await _localizedEntityService.ApplyLocalizedSettingAsync(seoSettings, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId, storeScope); await _localizedEntityService.ApplyLocalizedSettingAsync(seoSettings, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId, storeScope); } homePageSeoSettings.MetaTitle = model.HomepageSettings.MetaTitle; homePageSeoSettings.MetaDescription = model.HomepageSettings.MetaDescription; homePageSeoSettings.MetaKeywords = model.HomepageSettings.MetaKeywords; foreach (var localized in model.HomepageSettings.Locales) { await _localizedEntityService.ApplyLocalizedSettingAsync(homePageSeoSettings, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId, storeScope); await _localizedEntityService.ApplyLocalizedSettingAsync(homePageSeoSettings, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId, storeScope); await _localizedEntityService.ApplyLocalizedSettingAsync(homePageSeoSettings, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId, storeScope); } await _db.SaveChangesAsync(); if (resetUserSeoCharacterTable) { SeoHelper.ResetUserSeoCharacterTable(); } // TODO: (mh) (core) Do this right, if still needed. //if (clearSeoFriendlyUrls) //{ // LocalizedRoute.ClearSeoFriendlyUrlsCachedValue(); //} #endregion // Does not contain any store specific settings. await Services.SettingFactory.SaveSettingsAsync(securitySettings); return(NotifyAndRedirect("GeneralCommon")); }
public virtual ActionResult GeneralCommon() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } this.Server.ScriptTimeout = 300; var model = new GeneralCommonSettingsModel(); //blog information var blogInformationSettings = _settingService.LoadSetting <BlogInformationSettings>(); var commonSettings = _settingService.LoadSetting <CommonSettings>(); model.BlogInformationSettings.BlogClosed = blogInformationSettings.BlogClosed; //themes //TODO Themes Settings //EU Cookie law model.BlogInformationSettings.DisplayEuCookieLawWarning = blogInformationSettings.DisplayEuCookieLawWarning; //social pages model.BlogInformationSettings.GitHubLink = blogInformationSettings.GitHubLink; //sitemap model.BlogInformationSettings.SitemapEnabled = commonSettings.SitemapEnabled; //seo settings var seoSettings = _settingService.LoadSetting <SeoSettings>(); model.SeoSettings.PageTitleSeparator = seoSettings.PageTitleSeparator; model.SeoSettings.PageTitleSeoAdjustment = (int)seoSettings.PageTitleSeoAdjustment; model.SeoSettings.PageTitleSeoAdjustmentValues = seoSettings.PageTitleSeoAdjustment.ToSelectList(); model.SeoSettings.DefaultTitle = seoSettings.DefaultTitle; model.SeoSettings.DefaultMetaKeywords = seoSettings.DefaultMetaKeywords; model.SeoSettings.DefaultMetaDescription = seoSettings.DefaultMetaDescription; model.SeoSettings.WwwRequirement = (int)seoSettings.WwwRequirement; model.SeoSettings.WwwRequirementValues = seoSettings.WwwRequirement.ToSelectList(); model.SeoSettings.EnableJsBundling = seoSettings.EnableJsBundling; model.SeoSettings.EnableCssBundling = seoSettings.EnableCssBundling; model.SeoSettings.CustomHeadTags = seoSettings.CustomHeadTags; //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(); model.SecuritySettings.EncryptionKey = securitySettings.EncryptionKey; if (securitySettings.AdminAreaAllowedIpAddresses != null) { for (int i = 0; i < securitySettings.AdminAreaAllowedIpAddresses.Count; i++) { model.SecuritySettings.AdminAreaAllowedIpAddresses += securitySettings.AdminAreaAllowedIpAddresses[i]; if (i != securitySettings.AdminAreaAllowedIpAddresses.Count - 1) { model.SecuritySettings.AdminAreaAllowedIpAddresses += ","; } } } model.SecuritySettings.ForceSslForAllPages = securitySettings.ForceSslForAllPages; model.SecuritySettings.EnableXsrfProtectionForAdminArea = securitySettings.EnableXsrfProtectionForAdminArea; model.SecuritySettings.EnableXsrfProtectionForPublicArea = securitySettings.EnableXsrfProtectionForPublicArea; model.SecuritySettings.HoneypotEnabled = securitySettings.HoneypotEnabled; //captcha settings var captchaSettings = _settingService.LoadSetting <CaptchaSettings>(); model.CaptchaSettings.Enabled = captchaSettings.Enabled; model.CaptchaSettings.ShowOnLoginPage = captchaSettings.ShowOnLoginPage; model.CaptchaSettings.ShowOnPublishBlogCommentPage = captchaSettings.ShowOnPublishBlogCommentPage; model.CaptchaSettings.ShowOnPublishBlogPostPage = captchaSettings.ShowOnPublishBlogPostPage; model.CaptchaSettings.ShowOnRegistrationPage = captchaSettings.ShowOnRegistrationPage; //localization var localizationSettings = _settingService.LoadSetting <LocalizationSettings>(); model.LocalizationSettings.UseImagesForLanguageSelection = localizationSettings.UseImagesForLanguageSelection; model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled = localizationSettings.SeoFriendlyUrlsForLanguagesEnabled; model.LocalizationSettings.AutomaticallyDetectLanguage = localizationSettings.AutomaticallyDetectLanguage; model.LocalizationSettings.LoadAllLocaleRecordsOnStartup = localizationSettings.LoadAllLocaleRecordsOnStartup; model.LocalizationSettings.LoadAllLocalizedPropertiesOnStartup = localizationSettings.LoadAllLocalizedPropertiesOnStartup; model.LocalizationSettings.LoadAllUrlRecordsOnStartup = localizationSettings.LoadAllUrlRecordsOnStartup; return(View(model)); }
public async Task <IActionResult> GeneralCommon( int storeScope, StoreInformationSettings storeInformationSettings, SeoSettings seoSettings, DateTimeSettings dateTimeSettings, SecuritySettings securitySettings, CaptchaSettings captchaSettings, PdfSettings pdfSettings, LocalizationSettings localizationSettings, CompanyInformationSettings companySettings, ContactDataSettings contactDataSettings, BankConnectionSettings bankConnectionSettings, SocialSettings socialSettings, HomePageSettings homePageSettings) { var model = new GeneralCommonSettingsModel(); // Map entities to model. MiniMapper.Map(storeInformationSettings, model.StoreInformationSettings); MiniMapper.Map(seoSettings, model.SeoSettings); MiniMapper.Map(dateTimeSettings, model.DateTimeSettings); MiniMapper.Map(securitySettings, model.SecuritySettings); MiniMapper.Map(captchaSettings, model.CaptchaSettings); MiniMapper.Map(pdfSettings, model.PdfSettings); MiniMapper.Map(localizationSettings, model.LocalizationSettings); MiniMapper.Map(companySettings, model.CompanyInformationSettings); MiniMapper.Map(contactDataSettings, model.ContactDataSettings); MiniMapper.Map(bankConnectionSettings, model.BankConnectionSettings); MiniMapper.Map(socialSettings, model.SocialSettings); MiniMapper.Map(homePageSettings, model.HomepageSettings); #region SEO custom mapping // Fix for Disallows & Allows joined with comma in MiniMapper (we need NewLine). model.SeoSettings.ExtraRobotsDisallows = seoSettings.ExtraRobotsDisallows != null?string.Join(Environment.NewLine, seoSettings.ExtraRobotsDisallows) : string.Empty; model.SeoSettings.ExtraRobotsAllows = seoSettings.ExtraRobotsAllows != null?string.Join(Environment.NewLine, seoSettings.ExtraRobotsAllows) : string.Empty; model.SeoSettings.MetaTitle = seoSettings.MetaTitle; model.SeoSettings.MetaDescription = seoSettings.MetaDescription; model.SeoSettings.MetaKeywords = seoSettings.MetaKeywords; AddLocales(model.SeoSettings.Locales, (locale, languageId) => { locale.MetaTitle = seoSettings.GetLocalizedSetting(x => x.MetaTitle, languageId, storeScope, false, false); locale.MetaDescription = seoSettings.GetLocalizedSetting(x => x.MetaDescription, languageId, storeScope, false, false); locale.MetaKeywords = seoSettings.GetLocalizedSetting(x => x.MetaKeywords, languageId, storeScope, false, false); }); model.HomepageSettings.MetaTitle = homePageSettings.MetaTitle; model.HomepageSettings.MetaDescription = homePageSettings.MetaDescription; model.HomepageSettings.MetaKeywords = homePageSettings.MetaKeywords; AddLocales(model.HomepageSettings.Locales, (locale, languageId) => { locale.MetaTitle = homePageSettings.GetLocalizedSetting(x => x.MetaTitle, languageId, storeScope, false, false); locale.MetaDescription = homePageSettings.GetLocalizedSetting(x => x.MetaDescription, languageId, storeScope, false, false); locale.MetaKeywords = homePageSettings.GetLocalizedSetting(x => x.MetaKeywords, languageId, storeScope, false, false); }); #endregion await PrepareConfigurationModelAsync(model); return(View(model)); }
public virtual IActionResult GeneralCommon(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } //site information settings var siteInformationSettings = _settingService.LoadSetting <SiteInformationSettings>(); var commonSettings = _settingService.LoadSetting <CommonSettings>(); siteInformationSettings.DefaultSiteTheme = model.SiteInformationSettings.DefaultSiteTheme; siteInformationSettings.AllowUserToSelectTheme = model.SiteInformationSettings.AllowUserToSelectTheme; siteInformationSettings.LogoPictureId = model.SiteInformationSettings.LogoPictureId; //EU Cookie law siteInformationSettings.DisplayEuCookieLawWarning = model.SiteInformationSettings.DisplayEuCookieLawWarning; //social pages siteInformationSettings.FacebookLink = model.SiteInformationSettings.FacebookLink; siteInformationSettings.TwitterLink = model.SiteInformationSettings.TwitterLink; siteInformationSettings.YoutubeLink = model.SiteInformationSettings.YoutubeLink; siteInformationSettings.GooglePlusLink = model.SiteInformationSettings.GooglePlusLink; //contact us commonSettings.SubjectFieldOnContactUsForm = model.SiteInformationSettings.SubjectFieldOnContactUsForm; commonSettings.UseSystemEmailForContactUsForm = model.SiteInformationSettings.UseSystemEmailForContactUsForm; //terms of service commonSettings.PopupForTermsOfServiceLinks = model.SiteInformationSettings.PopupForTermsOfServiceLinks; //sitemap commonSettings.SitemapEnabled = model.SiteInformationSettings.SitemapEnabled; commonSettings.SitemapPageSize = model.SiteInformationSettings.SitemapPageSize; //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update _settingService.SaveSettingOverridable(siteInformationSettings, x => x.DefaultSiteTheme, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.AllowUserToSelectTheme, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.LogoPictureId, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.DisplayEuCookieLawWarning, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.FacebookLink, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.TwitterLink, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.YoutubeLink, true); _settingService.SaveSettingOverridable(siteInformationSettings, x => x.GooglePlusLink, true); _settingService.SaveSettingOverridable(commonSettings, x => x.SubjectFieldOnContactUsForm, true); _settingService.SaveSettingOverridable(commonSettings, x => x.UseSystemEmailForContactUsForm, true); _settingService.SaveSettingOverridable(commonSettings, x => x.PopupForTermsOfServiceLinks, true); _settingService.SaveSettingOverridable(commonSettings, x => x.SitemapEnabled, true); _settingService.SaveSettingOverridable(commonSettings, x => x.SitemapPageSize, true); //now clear settings cache _settingService.ClearCache(); //seo settings var seoSettings = _settingService.LoadSetting <SeoSettings>(); seoSettings.PageTitleSeparator = model.SeoSettings.PageTitleSeparator; seoSettings.PageTitleSeoAdjustment = (PageTitleSeoAdjustment)model.SeoSettings.PageTitleSeoAdjustment; seoSettings.DefaultTitle = model.SeoSettings.DefaultTitle; seoSettings.DefaultMetaKeywords = model.SeoSettings.DefaultMetaKeywords; seoSettings.DefaultMetaDescription = model.SeoSettings.DefaultMetaDescription; seoSettings.GenerateProductMetaDescription = model.SeoSettings.GenerateProductMetaDescription; seoSettings.ConvertNonWesternChars = model.SeoSettings.ConvertNonWesternChars; seoSettings.CanonicalUrlsEnabled = model.SeoSettings.CanonicalUrlsEnabled; seoSettings.WwwRequirement = (WwwRequirement)model.SeoSettings.WwwRequirement; seoSettings.EnableJsBundling = model.SeoSettings.EnableJsBundling; seoSettings.EnableCssBundling = model.SeoSettings.EnableCssBundling; seoSettings.TwitterMetaTags = model.SeoSettings.TwitterMetaTags; seoSettings.OpenGraphMetaTags = model.SeoSettings.OpenGraphMetaTags; seoSettings.CustomHeadTags = model.SeoSettings.CustomHeadTags; //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update _settingService.SaveSettingOverridable(seoSettings, x => x.PageTitleSeparator, true); _settingService.SaveSettingOverridable(seoSettings, x => x.PageTitleSeoAdjustment, true); _settingService.SaveSettingOverridable(seoSettings, x => x.DefaultTitle, true); _settingService.SaveSettingOverridable(seoSettings, x => x.DefaultMetaKeywords, true); _settingService.SaveSettingOverridable(seoSettings, x => x.DefaultMetaDescription, true); _settingService.SaveSettingOverridable(seoSettings, x => x.GenerateProductMetaDescription, true); _settingService.SaveSettingOverridable(seoSettings, x => x.ConvertNonWesternChars, true); _settingService.SaveSettingOverridable(seoSettings, x => x.CanonicalUrlsEnabled, true); _settingService.SaveSettingOverridable(seoSettings, x => x.WwwRequirement, true); _settingService.SaveSettingOverridable(seoSettings, x => x.EnableJsBundling, true); _settingService.SaveSettingOverridable(seoSettings, x => x.EnableCssBundling, true); _settingService.SaveSettingOverridable(seoSettings, x => x.TwitterMetaTags, true); _settingService.SaveSettingOverridable(seoSettings, x => x.OpenGraphMetaTags, true); _settingService.SaveSettingOverridable(seoSettings, x => x.CustomHeadTags, true); //now clear settings cache _settingService.ClearCache(); //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(); if (securitySettings.AdminAreaAllowedIpAddresses == null) { securitySettings.AdminAreaAllowedIpAddresses = new List <string>(); } securitySettings.AdminAreaAllowedIpAddresses.Clear(); if (!string.IsNullOrEmpty(model.SecuritySettings.AdminAreaAllowedIpAddresses)) { foreach (var s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrWhiteSpace(s)) { securitySettings.AdminAreaAllowedIpAddresses.Add(s.Trim()); } } } securitySettings.ForceSslForAllPages = model.SecuritySettings.ForceSslForAllPages; securitySettings.EnableXsrfProtectionForAdminArea = model.SecuritySettings.EnableXsrfProtectionForAdminArea; securitySettings.EnableXsrfProtectionForSite = model.SecuritySettings.EnableXsrfProtectionForPublicSite; securitySettings.HoneypotEnabled = model.SecuritySettings.HoneypotEnabled; _settingService.SaveSetting(securitySettings); //captcha settings var captchaSettings = _settingService.LoadSetting <CaptchaSettings>(); captchaSettings.Enabled = model.CaptchaSettings.Enabled; captchaSettings.ShowOnLoginPage = model.CaptchaSettings.ShowOnLoginPage; captchaSettings.ShowOnRegistrationPage = model.CaptchaSettings.ShowOnRegistrationPage; captchaSettings.ShowOnContactUsPage = model.CaptchaSettings.ShowOnContactUsPage; captchaSettings.ReCaptchaPublicKey = model.CaptchaSettings.ReCaptchaPublicKey; captchaSettings.ReCaptchaPrivateKey = model.CaptchaSettings.ReCaptchaPrivateKey; //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update _settingService.SaveSettingOverridable(captchaSettings, x => x.Enabled, true); _settingService.SaveSettingOverridable(captchaSettings, x => x.ShowOnLoginPage, true); _settingService.SaveSettingOverridable(captchaSettings, x => x.ShowOnRegistrationPage, true); _settingService.SaveSettingOverridable(captchaSettings, x => x.ShowOnContactUsPage, true); _settingService.SaveSettingOverridable(captchaSettings, x => x.ReCaptchaPublicKey, true); _settingService.SaveSettingOverridable(captchaSettings, x => x.ReCaptchaPrivateKey, true); // now clear settings cache _settingService.ClearCache(); if (captchaSettings.Enabled && (string.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPublicKey) || string.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPrivateKey))) { //captcha is enabled but the keys are not entered ErrorNotification(_localizationService.GetResource("Admin.Configuration.Settings.GeneralCommon.CaptchaAppropriateKeysNotEnteredError")); } //PDF settings var pdfSettings = _settingService.LoadSetting <PdfSettings>(); pdfSettings.LetterPageSizeEnabled = model.PdfSettings.LetterPageSizeEnabled; pdfSettings.LogoPictureId = model.PdfSettings.LogoPictureId; //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update _settingService.SaveSettingOverridable(pdfSettings, x => x.LetterPageSizeEnabled, true); _settingService.SaveSettingOverridable(pdfSettings, x => x.LogoPictureId, true); //now clear settings cache _settingService.ClearCache(); //localization settings var localizationSettings = _settingService.LoadSetting <LocalizationSettings>(); localizationSettings.UseImagesForLanguageSelection = model.LocalizationSettings.UseImagesForLanguageSelection; if (localizationSettings.SeoFriendlyUrlsForLanguagesEnabled != model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled) { localizationSettings.SeoFriendlyUrlsForLanguagesEnabled = model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled; //clear cached values of routes RouteData.Routers.ClearSeoFriendlyUrlsCachedValueForRoutes(); } localizationSettings.AutomaticallyDetectLanguage = model.LocalizationSettings.AutomaticallyDetectLanguage; localizationSettings.LoadAllLocaleRecordsOnStartup = model.LocalizationSettings.LoadAllLocaleRecordsOnStartup; localizationSettings.LoadAllLocalizedPropertiesOnStartup = model.LocalizationSettings.LoadAllLocalizedPropertiesOnStartup; localizationSettings.LoadAllUrlRecordsOnStartup = model.LocalizationSettings.LoadAllUrlRecordsOnStartup; _settingService.SaveSetting(localizationSettings); //full-text (not overridable) commonSettings = _settingService.LoadSetting <CommonSettings>(); commonSettings.FullTextMode = (FulltextSearchMode)model.FullTextSettings.SearchMode; _settingService.SaveSetting(commonSettings); //display default menu item var displayDefaultMenuItemSettings = _settingService.LoadSetting <DisplayDefaultMenuItemSettings>(); //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update displayDefaultMenuItemSettings.DisplayHomePageMenuItem = model.DisplayDefaultMenuItemSettings.DisplayHomePageMenuItem; displayDefaultMenuItemSettings.DisplayUserInfoMenuItem = model.DisplayDefaultMenuItemSettings.DisplayUserInfoMenuItem; displayDefaultMenuItemSettings.DisplayContactUsMenuItem = model.DisplayDefaultMenuItemSettings.DisplayContactUsMenuItem; _settingService.SaveSettingOverridable(displayDefaultMenuItemSettings, x => x.DisplayHomePageMenuItem, true); _settingService.SaveSettingOverridable(displayDefaultMenuItemSettings, x => x.DisplayUserInfoMenuItem, true); _settingService.SaveSettingOverridable(displayDefaultMenuItemSettings, x => x.DisplayContactUsMenuItem, true); //now clear settings cache _settingService.ClearCache(); //display default footer item var displayDefaultFooterItemSettings = _settingService.LoadSetting <DisplayDefaultFooterItemSettings>(); //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update displayDefaultFooterItemSettings.DisplaySitemapFooterItem = model.DisplayDefaultFooterItemSettings.DisplaySitemapFooterItem; displayDefaultFooterItemSettings.DisplayContactUsFooterItem = model.DisplayDefaultFooterItemSettings.DisplayContactUsFooterItem; displayDefaultFooterItemSettings.DisplayUserInfoFooterItem = model.DisplayDefaultFooterItemSettings.DisplayUserInfoFooterItem; displayDefaultFooterItemSettings.DisplayUserAddressesFooterItem = model.DisplayDefaultFooterItemSettings.DisplayUserAddressesFooterItem; _settingService.SaveSettingOverridable(displayDefaultFooterItemSettings, x => x.DisplaySitemapFooterItem, true); _settingService.SaveSettingOverridable(displayDefaultFooterItemSettings, x => x.DisplayContactUsFooterItem, true); _settingService.SaveSettingOverridable(displayDefaultFooterItemSettings, x => x.DisplayUserInfoFooterItem, true); _settingService.SaveSettingOverridable(displayDefaultFooterItemSettings, x => x.DisplayUserAddressesFooterItem, true); //now clear settings cache _settingService.ClearCache(); //admin area var adminAreaSettings = _settingService.LoadSetting <AdminAreaSettings>(); //we do not clear cache after each setting update. //this behavior can increase performance because cached settings will not be cleared //and loaded from database after each update adminAreaSettings.UseRichEditorInMessageTemplates = model.AdminAreaSettings.UseRichEditorInMessageTemplates; _settingService.SaveSettingOverridable(adminAreaSettings, x => x.UseRichEditorInMessageTemplates, true); //now clear settings cache _settingService.ClearCache(); //activity log _userActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings")); SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated")); return(RedirectToAction("GeneralCommon")); }
private async Task PrepareConfigurationModelAsync(GeneralCommonSettingsModel model) { foreach (var timeZone in _dateTimeHelper.GetSystemTimeZones()) { model.DateTimeSettings.AvailableTimeZones.Add(new SelectListItem { Text = timeZone.DisplayName, Value = timeZone.Id, Selected = timeZone.Id.Equals(_dateTimeHelper.DefaultStoreTimeZone.Id, StringComparison.InvariantCultureIgnoreCase) }); } #region CompanyInfo custom mapping ViewBag.AvailableCountries = new List <SelectListItem> { new SelectListItem { Text = T("Common.Unspecified"), Value = "0" } }; ViewBag.Salutations = new List <SelectListItem>(); var countries = await _db.Countries .AsNoTracking() .ApplyStandardFilter() .ToListAsync(); foreach (var c in countries) { ViewBag.AvailableCountries.Add(new SelectListItem { Text = c.GetLocalized(x => x.Name), Value = c.Id.ToString(), Selected = c.Id == model.CompanyInformationSettings.CountryId }); } ViewBag.Salutations = new List <SelectListItem>(); ViewBag.Salutations.AddRange(new[] { ResToSelectListItem("Admin.Address.Salutation.Mr"), ResToSelectListItem("Admin.Address.Salutation.Mrs") }); var resRoot = "Admin.Configuration.Settings.GeneralCommon.CompanyInformationSettings.ManagementDescriptions."; ViewBag.ManagementDescriptions = new List <SelectListItem>(); ViewBag.ManagementDescriptions.AddRange(new[] { ResToSelectListItem(resRoot + "Manager"), ResToSelectListItem(resRoot + "Shopkeeper"), ResToSelectListItem(resRoot + "Procurator"), ResToSelectListItem(resRoot + "Shareholder"), ResToSelectListItem(resRoot + "AuthorizedPartner"), ResToSelectListItem(resRoot + "Director"), ResToSelectListItem(resRoot + "ManagingPartner") }); ViewBag.AvailableMetaContentValues = new List <SelectListItem> { new SelectListItem { Text = "index", Value = "index" }, new SelectListItem { Text = "noindex", Value = "noindex" }, new SelectListItem { Text = "index, follow", Value = "index, follow" }, new SelectListItem { Text = "index, nofollow", Value = "index, nofollow" }, new SelectListItem { Text = "noindex, follow", Value = "noindex, follow" }, new SelectListItem { Text = "noindex, nofollow", Value = "noindex, nofollow" } }; #endregion }
public virtual ActionResult GeneralCommon(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } //blog information settings var blogInformationSettings = _settingService.LoadSetting <BlogInformationSettings>(); var commonSettings = _settingService.LoadSetting <CommonSettings>(); blogInformationSettings.BlogClosed = model.BlogInformationSettings.BlogClosed; //EU Cookie law blogInformationSettings.DisplayEuCookieLawWarning = model.BlogInformationSettings.DisplayEuCookieLawWarning; //social pages blogInformationSettings.GitHubLink = model.BlogInformationSettings.GitHubLink; //sitemap commonSettings.SitemapEnabled = model.BlogInformationSettings.SitemapEnabled; _settingService.SaveSetting(blogInformationSettings, settings => settings.BlogClosed, false); _settingService.SaveSetting(blogInformationSettings, settings => settings.DisplayEuCookieLawWarning, false); _settingService.SaveSetting(blogInformationSettings, settings => settings.GitHubLink, false); _settingService.SaveSetting(commonSettings, settings => settings.SitemapEnabled, false); _settingService.ClearCache(); //seo settings var seoSettings = _settingService.LoadSetting <SeoSettings>(); seoSettings.PageTitleSeparator = model.SeoSettings.PageTitleSeparator; seoSettings.PageTitleSeoAdjustment = (PageTitleSeoAdjustment)model.SeoSettings.PageTitleSeoAdjustment; seoSettings.DefaultTitle = model.SeoSettings.DefaultTitle; seoSettings.DefaultMetaKeywords = model.SeoSettings.DefaultMetaKeywords; seoSettings.DefaultMetaDescription = model.SeoSettings.DefaultMetaDescription; seoSettings.WwwRequirement = (WwwRequirement)model.SeoSettings.WwwRequirement; seoSettings.EnableJsBundling = model.SeoSettings.EnableJsBundling; seoSettings.EnableCssBundling = model.SeoSettings.EnableCssBundling; seoSettings.CustomHeadTags = model.SeoSettings.CustomHeadTags; _settingService.SaveSetting(seoSettings); //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(); if (securitySettings.AdminAreaAllowedIpAddresses == null) { securitySettings.AdminAreaAllowedIpAddresses = new List <string>(); } securitySettings.AdminAreaAllowedIpAddresses.Clear(); if (!string.IsNullOrEmpty(model.SecuritySettings.AdminAreaAllowedIpAddresses)) { foreach (string s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrWhiteSpace(s)) { securitySettings.AdminAreaAllowedIpAddresses.Add(s.Trim()); } } } securitySettings.ForceSslForAllPages = model.SecuritySettings.ForceSslForAllPages; securitySettings.EnableXsrfProtectionForAdminArea = model.SecuritySettings.EnableXsrfProtectionForAdminArea; securitySettings.EnableXsrfProtectionForPublicArea = model.SecuritySettings.EnableXsrfProtectionForPublicArea; securitySettings.HoneypotEnabled = model.SecuritySettings.HoneypotEnabled; _settingService.SaveSetting(securitySettings); //captcha settings var captchaSettings = _settingService.LoadSetting <CaptchaSettings>(); captchaSettings.Enabled = model.CaptchaSettings.Enabled; captchaSettings.ShowOnLoginPage = model.CaptchaSettings.ShowOnLoginPage; captchaSettings.ShowOnPublishBlogCommentPage = model.CaptchaSettings.ShowOnPublishBlogCommentPage; captchaSettings.ShowOnPublishBlogPostPage = model.CaptchaSettings.ShowOnPublishBlogPostPage; captchaSettings.ShowOnRegistrationPage = model.CaptchaSettings.ShowOnRegistrationPage; _settingService.SaveSetting(captchaSettings); //localize var localizationSettings = _settingService.LoadSetting <LocalizationSettings>(); localizationSettings.UseImagesForLanguageSelection = model.LocalizationSettings.UseImagesForLanguageSelection; if (localizationSettings.SeoFriendlyUrlsForLanguagesEnabled != model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled) { localizationSettings.SeoFriendlyUrlsForLanguagesEnabled = model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled; //clear cached values of routes System.Web.Routing.RouteTable.Routes.ClearSeoFriendlyUrlsCachedValueForRoutes(); } localizationSettings.AutomaticallyDetectLanguage = model.LocalizationSettings.AutomaticallyDetectLanguage; localizationSettings.LoadAllLocaleRecordsOnStartup = model.LocalizationSettings.LoadAllLocaleRecordsOnStartup; localizationSettings.LoadAllLocalizedPropertiesOnStartup = model.LocalizationSettings.LoadAllLocalizedPropertiesOnStartup; localizationSettings.LoadAllUrlRecordsOnStartup = model.LocalizationSettings.LoadAllUrlRecordsOnStartup; _settingService.SaveSetting(localizationSettings); _customerActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings")); SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated")); return(RedirectToAction("GeneralCommon")); }
public ActionResult GeneralCommon(GeneralCommonSettingsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } //store information settings var storeInformationSettings = _settingService.LoadSetting <StoreInformationSettings>(); var commonSettings = _settingService.LoadSetting <CommonSettings>(); storeInformationSettings.StoreClosed = model.StoreInformationSettings.StoreClosed; storeInformationSettings.DefaultStoreTheme = model.StoreInformationSettings.DefaultStoreTheme; storeInformationSettings.AllowCustomerToSelectTheme = model.StoreInformationSettings.AllowCustomerToSelectTheme; storeInformationSettings.Name = model.StoreInformationSettings.Name; storeInformationSettings.Url = model.StoreInformationSettings.Url; if (!string.IsNullOrWhiteSpace(storeInformationSettings.Url) && !storeInformationSettings.Url.EndsWith("/")) { storeInformationSettings.Url += "/"; } storeInformationSettings.SslEnabled = model.StoreInformationSettings.SslEnabled; storeInformationSettings.Hosts = model.StoreInformationSettings.Hosts; //social var socialSettings = _settingService.LoadSetting <SocialSettings>(); socialSettings.FacebookAppId = model.SocialSettings.FacebookAppId; socialSettings.FacebookAppSecret = model.SocialSettings.FacebookAppSecret; _settingService.SaveSetting(socialSettings); //EU Cookie law storeInformationSettings.DisplayEuCookieLawWarning = model.StoreInformationSettings.DisplayEuCookieLawWarning; //social pages storeInformationSettings.FacebookLink = model.StoreInformationSettings.FacebookLink; storeInformationSettings.TwitterLink = model.StoreInformationSettings.TwitterLink; storeInformationSettings.YoutubeLink = model.StoreInformationSettings.YoutubeLink; storeInformationSettings.GooglePlusLink = model.StoreInformationSettings.GooglePlusLink; //contact us commonSettings.SubjectFieldOnContactUsForm = model.StoreInformationSettings.SubjectFieldOnContactUsForm; commonSettings.UseSystemEmailForContactUsForm = model.StoreInformationSettings.UseSystemEmailForContactUsForm; _settingService.SaveSetting(storeInformationSettings, x => x.StoreClosed, false); _settingService.SaveSetting(storeInformationSettings, x => x.DefaultStoreTheme, false); _settingService.SaveSetting(storeInformationSettings, x => x.AllowCustomerToSelectTheme, false); _settingService.SaveSetting(storeInformationSettings, x => x.DisplayEuCookieLawWarning, false); _settingService.SaveSetting(storeInformationSettings, x => x.FacebookLink, false); _settingService.SaveSetting(storeInformationSettings, x => x.TwitterLink, false); _settingService.SaveSetting(storeInformationSettings, x => x.YoutubeLink, false); _settingService.SaveSetting(storeInformationSettings, x => x.GooglePlusLink, false); _settingService.SaveSetting(commonSettings, x => x.SubjectFieldOnContactUsForm, false); _settingService.SaveSetting(commonSettings, x => x.UseSystemEmailForContactUsForm, false); _settingService.SaveSetting(storeInformationSettings); _settingService.SaveSetting(commonSettings); //seo settings var seoSettings = _settingService.LoadSetting <SeoSettings>(); seoSettings.PageTitleSeparator = model.SeoSettings.PageTitleSeparator; seoSettings.PageTitleSeoAdjustment = (PageTitleSeoAdjustment)model.SeoSettings.PageTitleSeoAdjustment; seoSettings.DefaultTitle = model.SeoSettings.DefaultTitle; seoSettings.DefaultMetaKeywords = model.SeoSettings.DefaultMetaKeywords; seoSettings.DefaultMetaDescription = model.SeoSettings.DefaultMetaDescription; seoSettings.GeneratePostMetaDescription = model.SeoSettings.GeneratePostMetaDescription; seoSettings.ConvertNonWesternChars = model.SeoSettings.ConvertNonWesternChars; seoSettings.CanonicalUrlsEnabled = model.SeoSettings.CanonicalUrlsEnabled; seoSettings.WwwRequirement = (WwwRequirement)model.SeoSettings.WwwRequirement; seoSettings.EnableJsBundling = model.SeoSettings.EnableJsBundling; seoSettings.EnableCssBundling = model.SeoSettings.EnableCssBundling; seoSettings.TwitterMetaTags = model.SeoSettings.TwitterMetaTags; seoSettings.OpenGraphMetaTags = model.SeoSettings.OpenGraphMetaTags; _settingService.SaveSetting(seoSettings, x => x.PageTitleSeparator, false); _settingService.SaveSetting(seoSettings, x => x.PageTitleSeoAdjustment, false); _settingService.SaveSetting(seoSettings, x => x.DefaultTitle, false); _settingService.SaveSetting(seoSettings, x => x.DefaultMetaKeywords, false); _settingService.SaveSetting(seoSettings, x => x.DefaultMetaDescription, false); _settingService.SaveSetting(seoSettings, x => x.GeneratePostMetaDescription, false); _settingService.SaveSetting(seoSettings, x => x.ConvertNonWesternChars, false); _settingService.SaveSetting(seoSettings, x => x.CanonicalUrlsEnabled, false); _settingService.SaveSetting(seoSettings, x => x.WwwRequirement, false); _settingService.SaveSetting(seoSettings, x => x.EnableJsBundling, false); _settingService.SaveSetting(seoSettings, x => x.EnableCssBundling, false); _settingService.SaveSetting(seoSettings, x => x.TwitterMetaTags, false); _settingService.SaveSetting(seoSettings, x => x.OpenGraphMetaTags, false); //security settings var securitySettings = _settingService.LoadSetting <SecuritySettings>(); var captchaSettings = _settingService.LoadSetting <CaptchaSettings>(); if (securitySettings.AdminAreaAllowedIpAddresses == null) { securitySettings.AdminAreaAllowedIpAddresses = new List <string>(); } securitySettings.AdminAreaAllowedIpAddresses.Clear(); if (!String.IsNullOrEmpty(model.SecuritySettings.AdminAreaAllowedIpAddresses)) { foreach ( var s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (!String.IsNullOrWhiteSpace(s)) { securitySettings.AdminAreaAllowedIpAddresses.Add(s.Trim()); } } } securitySettings.ForceSslForAllPages = model.SecuritySettings.ForceSslForAllPages; securitySettings.EnableXsrfProtectionForAdminArea = model.SecuritySettings.EnableXsrfProtectionForAdminArea; securitySettings.EnableXsrfProtectionForPublicStore = model.SecuritySettings.EnableXsrfProtectionForPublicStore; securitySettings.HoneypotEnabled = model.SecuritySettings.HoneypotEnabled; _settingService.SaveSetting(securitySettings); captchaSettings.Enabled = model.SecuritySettings.CaptchaEnabled; captchaSettings.ShowOnLoginPage = model.SecuritySettings.CaptchaShowOnLoginPage; captchaSettings.ShowOnRegistrationPage = model.SecuritySettings.CaptchaShowOnRegistrationPage; captchaSettings.ShowOnContactUsPage = model.SecuritySettings.CaptchaShowOnContactUsPage; captchaSettings.ShowOnEmailWishlistToFriendPage = model.SecuritySettings.CaptchaShowOnEmailWishlistToFriendPage; captchaSettings.ShowOnEmailPostToFriendPage = model.SecuritySettings.CaptchaShowOnEmailPostToFriendPage; captchaSettings.ShowOnBlogCommentPage = model.SecuritySettings.CaptchaShowOnBlogCommentPage; captchaSettings.ShowOnNewsCommentPage = model.SecuritySettings.CaptchaShowOnNewsCommentPage; captchaSettings.ShowOnPostReviewPage = model.SecuritySettings.CaptchaShowOnPostReviewPage; captchaSettings.ShowOnApplyVendorPage = model.SecuritySettings.CaptchaShowOnApplyVendorPage; captchaSettings.ReCaptchaPublicKey = model.SecuritySettings.ReCaptchaPublicKey; captchaSettings.ReCaptchaPrivateKey = model.SecuritySettings.ReCaptchaPrivateKey; _settingService.SaveSetting(captchaSettings); if (captchaSettings.Enabled && (String.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPublicKey) || String.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPrivateKey))) { //captcha is enabled but the keys are not entered ErrorNotification("Captcha is enabled but the appropriate keys are not entered"); } //localization settings var localizationSettings = _settingService.LoadSetting <LocalizationSettings>(); localizationSettings.UseImagesForLanguageSelection = model.LocalizationSettings.UseImagesForLanguageSelection; if (localizationSettings.SeoFriendlyUrlsForLanguagesEnabled != model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled) { localizationSettings.SeoFriendlyUrlsForLanguagesEnabled = model.LocalizationSettings.SeoFriendlyUrlsForLanguagesEnabled; //clear cached values of routes RouteTable.Routes.ClearSeoFriendlyUrlsCachedValueForRoutes(); } localizationSettings.AutomaticallyDetectLanguage = model.LocalizationSettings.AutomaticallyDetectLanguage; localizationSettings.LoadAllLocaleRecordsOnStartup = model.LocalizationSettings.LoadAllLocaleRecordsOnStartup; localizationSettings.LoadAllLocalizedPropertiesOnStartup = model.LocalizationSettings.LoadAllLocalizedPropertiesOnStartup; localizationSettings.LoadAllUrlRecordsOnStartup = model.LocalizationSettings.LoadAllUrlRecordsOnStartup; _settingService.SaveSetting(localizationSettings); //full-text commonSettings.FullTextMode = (FulltextSearchMode)model.FullTextSettings.SearchMode; _settingService.SaveSetting(commonSettings); _settingService.ClearCache(); //activity log _customerActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings")); SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated")); //selected tab SaveSelectedTabIndex(); return(RedirectToAction("GeneralCommon")); }