Inheritance: Nop.Web.Framework.Mvc.BaseNopModel
Exemplo n.º 1
0
        public ActionResult Forum(ForumSettingsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            _forumSettings = model.ToEntity(_forumSettings);
            _settingService.SaveSetting(_forumSettings);

            //activity log
            _customerActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings"));

            SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated"));
            return RedirectToAction("Forum");
        }
Exemplo n.º 2
0
        public ActionResult Forum(ForumSettingsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            //load settings for a chosen store scope
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var forumSettings = _settingService.LoadSetting<ForumSettings>(storeScope);
            forumSettings = model.ToEntity(forumSettings);

            /* 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 */
            if (model.ForumsEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ForumsEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ForumsEnabled, storeScope);

            if (model.RelativeDateTimeFormattingEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.RelativeDateTimeFormattingEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.RelativeDateTimeFormattingEnabled, storeScope);

            if (model.ShowCustomersPostCount_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ShowCustomersPostCount, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ShowCustomersPostCount, storeScope);

            if (model.AllowGuestsToCreatePosts_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.AllowGuestsToCreatePosts, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.AllowGuestsToCreatePosts, storeScope);

            if (model.AllowGuestsToCreateTopics_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.AllowGuestsToCreateTopics, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.AllowGuestsToCreateTopics, storeScope);

            if (model.AllowCustomersToEditPosts_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.AllowCustomersToEditPosts, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.AllowCustomersToEditPosts, storeScope);

            if (model.AllowCustomersToDeletePosts_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.AllowCustomersToDeletePosts, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.AllowCustomersToDeletePosts, storeScope);

            if (model.AllowCustomersToManageSubscriptions_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.AllowCustomersToManageSubscriptions, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.AllowCustomersToManageSubscriptions, storeScope);

            if (model.TopicsPageSize_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.TopicsPageSize, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.TopicsPageSize, storeScope);

            if (model.PostsPageSize_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.PostsPageSize, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.PostsPageSize, storeScope);

            if (model.ForumEditor_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ForumEditor, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ForumEditor, storeScope);

            if (model.SignaturesEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.SignaturesEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.SignaturesEnabled, storeScope);

            if (model.AllowPrivateMessages_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.AllowPrivateMessages, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.AllowPrivateMessages, storeScope);

            if (model.ShowAlertForPM_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ShowAlertForPM, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ShowAlertForPM, storeScope);

            if (model.NotifyAboutPrivateMessages_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.NotifyAboutPrivateMessages, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.NotifyAboutPrivateMessages, storeScope);

            if (model.ActiveDiscussionsFeedEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ActiveDiscussionsFeedEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ActiveDiscussionsFeedEnabled, storeScope);

            if (model.ActiveDiscussionsFeedCount_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ActiveDiscussionsFeedCount, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ActiveDiscussionsFeedCount, storeScope);

            if (model.ForumFeedsEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ForumFeedsEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ForumFeedsEnabled, storeScope);

            if (model.ForumFeedCount_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ForumFeedCount, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ForumFeedCount, storeScope);

            if (model.SearchResultsPageSize_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.SearchResultsPageSize, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.SearchResultsPageSize, storeScope);

            if (model.ActiveDiscussionsPageSize_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(forumSettings, x => x.ActiveDiscussionsPageSize, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(forumSettings, x => x.ActiveDiscussionsPageSize, storeScope);

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

            //activity log
            _customerActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings"));

            SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated"));
            return RedirectToAction("Forum");
        }