Beispiel #1
0
        private bool ValidateAkismetSettings(AdminSettingsViewModel adminSettingsViewModel)
        {
            if (!adminSettingsViewModel.AkismetEnabled)
                return true;

            Uri url;
            if (string.IsNullOrEmpty(adminSettingsViewModel.AkismetUrl) || !Uri.TryCreate(adminSettingsViewModel.AkismetUrl, UriKind.Absolute, out url))
            {
                ModelState.AddModelError("Akismet_Url", "Akismet url entered is invalid");
                return false;
            }

            if (string.IsNullOrEmpty(adminSettingsViewModel.AkismetKey))
            {
                ModelState.AddModelError("Akismet_Key", "Akismet key entered is invalid");
                return false;
            }

            return true;
        }
Beispiel #2
0
 public ActionResult Settings()
 {
     var akismetUrl = string.IsNullOrEmpty(SettingsRepository.BlogAkismetUrl)
                          ? GetRootUrl().TrimEnd('/')
                          : SettingsRepository.BlogAkismetUrl;
     var adminSettings = new AdminSettingsViewModel
     {
         BlogName = SettingsRepository.BlogName,
         BlogCaption = SettingsRepository.BlogCaption,
         BlogTheme = SettingsRepository.BlogTheme,
         BlogThemes = GetAvailableThemes(SettingsRepository.BlogTheme),
         BlogSocialSharing = SettingsRepository.BlogSocialSharing,
         BlogSyntaxHighlighting = SettingsRepository.BlogSyntaxHighlighting,
         PostsPerPage = SettingsRepository.BlogPostsPerPage,
         AkismetEnabled = SettingsRepository.BlogAkismetEnabled,
         AkismetDeleteSpam = SettingsRepository.BlogAkismetDeleteSpam,
         AkismetKey = SettingsRepository.BlogAkismetKey,
         AkismetUrl = akismetUrl,
         AdminEmailAddress = SettingsRepository.BlogAdminEmailAddress,
         BlogSmtpAddress = SettingsRepository.BlogSmtpAddress,
         ManageItemsPerPage = SettingsRepository.ManageItemsPerPage,
         BlogErrorAction = SettingsRepository.BlogSiteErrorEmailAction,
         Title = SettingsRepository.BlogName,
         DisqusEnabled = SettingsRepository.DisqusEnabled,
         DisqusShortName = SettingsRepository.BlogDisqusShortName
     };
     return View(adminSettings);
 }
Beispiel #3
0
        public ActionResult Settings(AdminSettingsViewModel adminSettingsViewModel)
        {
            adminSettingsViewModel.BlogThemes = GetAvailableThemes(adminSettingsViewModel.BlogTheme);

            if (ModelState.IsValid && ValidateAkismetSettings(adminSettingsViewModel))
            {
                SettingsRepository.BlogName = adminSettingsViewModel.BlogName;
                SettingsRepository.BlogCaption = adminSettingsViewModel.BlogCaption;
                SettingsRepository.BlogTheme = adminSettingsViewModel.BlogTheme;
                SettingsRepository.BlogSocialSharing = adminSettingsViewModel.BlogSocialSharing;
                SettingsRepository.BlogSyntaxHighlighting = adminSettingsViewModel.BlogSyntaxHighlighting;
                SettingsRepository.BlogPostsPerPage = adminSettingsViewModel.PostsPerPage;
                SettingsRepository.BlogAkismetEnabled = adminSettingsViewModel.AkismetEnabled;
                SettingsRepository.BlogAkismetDeleteSpam = adminSettingsViewModel.AkismetDeleteSpam;
                SettingsRepository.BlogAkismetKey = adminSettingsViewModel.AkismetKey;
                SettingsRepository.BlogAkismetUrl = adminSettingsViewModel.AkismetUrl;
                SettingsRepository.BlogAdminEmailAddress = adminSettingsViewModel.AdminEmailAddress;
                SettingsRepository.BlogSmtpAddress = adminSettingsViewModel.BlogSmtpAddress;

                if (!string.IsNullOrEmpty(adminSettingsViewModel.BlogSmtpPassword))
                {
                    SettingsRepository.BlogSmtpPassword = TripleDES.EncryptString(adminSettingsViewModel.BlogSmtpPassword);
                }

                SettingsRepository.ManageItemsPerPage = adminSettingsViewModel.ManageItemsPerPage;
                SettingsRepository.BlogSiteErrorEmailAction = adminSettingsViewModel.BlogErrorAction;
                SettingsRepository.DisqusEnabled = adminSettingsViewModel.DisqusEnabled;
                SettingsRepository.BlogDisqusShortName = adminSettingsViewModel.DisqusShortName;
            }

            adminSettingsViewModel.UpdateStatus = true;
            adminSettingsViewModel.Title = SettingsRepository.BlogName;

            return View(adminSettingsViewModel);
        }