Beispiel #1
0
        public async Task <bool> Save(ISiteSettings site)
        {
            int  passedInSiteId = site.SiteId;
            bool result         = false;

            if (site.SiteId == -1) // new site
            {
                site.SiteGuid = Guid.NewGuid();

                site.SiteId = dbSiteSettings.Create(
                    site.SiteGuid,
                    site.SiteName,
                    site.Skin,
                    site.Logo,
                    site.Icon,
                    site.AllowNewRegistration,
                    site.AllowUserSkins,
                    site.AllowPageSkins,
                    site.AllowHideMenuOnPages,
                    site.UseSecureRegistration,
                    site.UseSslOnAllPages,
                    string.Empty, // legacy defaultPageKeywords
                    string.Empty, // legacy defaultPageDescription
                    string.Empty, // legacy defaultPageEncoding
                    string.Empty, // legacy defaultAdditionalMetaTag
                    site.IsServerAdminSite,
                    site.UseLdapAuth,
                    site.AutoCreateLdapUserOnFirstLogin,
                    site.SiteLdapSettings.Server,
                    site.SiteLdapSettings.Port,
                    site.SiteLdapSettings.Domain,
                    site.SiteLdapSettings.RootDN,
                    site.SiteLdapSettings.UserDNKey,
                    site.AllowUserFullNameChange,
                    site.UseEmailForLogin,
                    site.ReallyDeleteUsers,
                    string.Empty, // legacy site.EditorSkin,
                    string.Empty, // legacy site.DefaultFriendlyUrlPatternEnum,
                    false,        // legacy site.EnableMyPageFeature,
                    site.EditorProviderName,
                    string.Empty, // legacy site.DatePickerProvider,
                    site.CaptchaProvider,
                    site.RecaptchaPrivateKey,
                    site.RecaptchaPublicKey,
                    site.WordpressApiKey,
                    site.MicrosoftClientId,
                    site.MicrosoftClientSecret,
                    site.AllowOpenIdAuth,
                    false,                           //legacy site.AllowWindowsLiveAuth,
                    site.GmapApiKey,
                    site.AddThisDotComUsername,      //apiKeyExtra2
                    site.GoogleAnalyticsAccountCode, //apiKeyExtra2
                    string.Empty,                    //legacy apiKeyExtra3
                    site.SiteFolderName,             // legacy apiKeyExtra4
                    site.PreferredHostName,          // legacy apiKeyExtra5
                    site.DisableDbAuth);

                result = site.SiteId > -1;
            }
            else
            {
                result = dbSiteSettings.Update(
                    site.SiteId,
                    site.SiteName,
                    site.Skin,
                    site.Logo,
                    site.Icon,
                    site.AllowNewRegistration,
                    site.AllowUserSkins,
                    site.AllowPageSkins,
                    site.AllowHideMenuOnPages,
                    site.UseSecureRegistration,
                    site.UseSslOnAllPages,
                    string.Empty, // legacy defaultPageKeywords
                    string.Empty, // legacy defaultPageDescription
                    string.Empty, // legacy defaultPageEncoding
                    string.Empty, // legacy defaultAdditionalMetaTag
                    site.IsServerAdminSite,
                    site.UseLdapAuth,
                    site.AutoCreateLdapUserOnFirstLogin,
                    site.SiteLdapSettings.Server,
                    site.SiteLdapSettings.Port,
                    site.SiteLdapSettings.Domain,
                    site.SiteLdapSettings.RootDN,
                    site.SiteLdapSettings.UserDNKey,
                    site.AllowUserFullNameChange,
                    site.UseEmailForLogin,
                    site.ReallyDeleteUsers,
                    string.Empty, // legacy site.EditorSkin,
                    string.Empty, // legacy site.DefaultFriendlyUrlPatternEnum,
                    false,        // legacy site.EnableMyPageFeature,
                    site.EditorProviderName,
                    string.Empty, // legacy site.DatePickerProvider,
                    site.CaptchaProvider,
                    site.RecaptchaPrivateKey,
                    site.RecaptchaPublicKey,
                    site.WordpressApiKey,
                    site.MicrosoftClientId,
                    site.MicrosoftClientSecret,
                    site.AllowOpenIdAuth,
                    false,                           //legacy site.AllowWindowsLiveAuth,
                    site.GmapApiKey,
                    site.AddThisDotComUsername,      //apiKeyExtra2
                    site.GoogleAnalyticsAccountCode, //apiKeyExtra2
                    string.Empty,                    //legacy apiKeyExtra3
                    site.SiteFolderName,             // legacy apiKeyExtra4
                    site.PreferredHostName,          // legacy apiKeyExtra5
                    site.DisableDbAuth);
            }

            if (!result)
            {
                return(result);
            }

            // settings below stored as key value pairs in mp_SiteSettingsEx


            dbSiteSettingsEx.EnsureSettings();

            List <ExpandoSetting> expandoProperties = GetExpandoProperties(passedInSiteId); //-1 on new sites to get the default values

            // update a local data table of expando properties if the value changed and mark the row dirty
            site.SetExpandoSettings(expandoProperties);
            // finally update the database only with properties in the table marked as dirty
            SaveExpandoProperties(site.SiteId, site.SiteGuid, expandoProperties);

            return(result);
        }
Beispiel #2
0
        public async Task <bool> Save(ISiteSettings site, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            int  passedInSiteId = site.SiteId;
            bool result         = false;

            if (site.SiteId == -1) // new site
            {
                site.SiteGuid = Guid.NewGuid();

                site.SiteId = dbSiteSettings.Create(
                    site.SiteGuid,
                    site.SiteName,
                    site.Layout,
                    site.AllowNewRegistration,
                    site.UseSecureRegistration,
                    site.UseSslOnAllPages,
                    site.IsServerAdminSite,
                    site.UseLdapAuth,
                    site.AutoCreateLdapUserOnFirstLogin,
                    site.LdapServer,
                    site.LdapPort,
                    site.LdapDomain,
                    site.LdapRootDN,
                    site.LdapUserDNKey,
                    site.AllowUserFullNameChange,
                    site.UseEmailForLogin,
                    site.ReallyDeleteUsers,
                    site.RecaptchaPrivateKey,
                    site.RecaptchaPublicKey,
                    site.ApiKeyExtra1,
                    site.ApiKeyExtra2,
                    site.ApiKeyExtra3,
                    site.ApiKeyExtra4,
                    site.ApiKeyExtra5,
                    site.DisableDbAuth,

                    site.RequiresQuestionAndAnswer,
                    site.MaxInvalidPasswordAttempts,
                    site.PasswordAttemptWindowMinutes,
                    site.MinRequiredPasswordLength,
                    site.MinReqNonAlphaChars,
                    site.DefaultEmailFromAddress,
                    site.AllowDbFallbackWithLdap,
                    site.EmailLdapDbFallback,
                    site.AllowPersistentLogin,
                    site.CaptchaOnLogin,
                    site.CaptchaOnRegistration,
                    site.SiteIsClosed,
                    site.SiteIsClosedMessage,
                    site.PrivacyPolicy,
                    site.TimeZoneId,
                    site.GoogleAnalyticsProfileId,
                    site.CompanyName,
                    site.CompanyStreetAddress,
                    site.CompanyStreetAddress2,
                    site.CompanyRegion,
                    site.CompanyLocality,
                    site.CompanyCountry,
                    site.CompanyPostalCode,
                    site.CompanyPublicEmail,
                    site.CompanyPhone,
                    site.CompanyFax,
                    site.FacebookAppId,
                    site.FacebookAppSecret,
                    site.GoogleClientId,
                    site.GoogleClientSecret,
                    site.TwitterConsumerKey,
                    site.TwitterConsumerSecret,
                    site.MicrosoftClientId,
                    site.MicrosoftClientSecret,
                    site.PreferredHostName,
                    site.SiteFolderName,
                    site.AddThisDotComUsername,
                    site.LoginInfoTop,
                    site.LoginInfoBottom,
                    site.RegistrationAgreement,
                    site.RegistrationPreamble,
                    site.SmtpServer,
                    site.SmtpPort,
                    site.SmtpUser,
                    site.SmtpPassword,
                    site.SmtpPreferredEncoding,
                    site.SmtpRequiresAuth,
                    site.SmtpUseSsl,
                    site.RequireApprovalBeforeLogin,
                    site.IsDataProtected,
                    site.CreatedUtc
                    );

                result = site.SiteId > -1;
            }
            else
            {
                result = dbSiteSettings.Update(
                    site.SiteId,
                    site.SiteName,
                    site.Layout,
                    site.AllowNewRegistration,
                    site.UseSecureRegistration,
                    site.UseSslOnAllPages,
                    site.IsServerAdminSite,
                    site.UseLdapAuth,
                    site.AutoCreateLdapUserOnFirstLogin,
                    site.LdapServer,
                    site.LdapPort,
                    site.LdapDomain,
                    site.LdapRootDN,
                    site.LdapUserDNKey,
                    site.AllowUserFullNameChange,
                    site.UseEmailForLogin,
                    site.ReallyDeleteUsers,
                    site.RecaptchaPrivateKey,
                    site.RecaptchaPublicKey,
                    site.ApiKeyExtra1,
                    site.ApiKeyExtra2,
                    site.ApiKeyExtra3,
                    site.ApiKeyExtra4,
                    site.ApiKeyExtra5,
                    site.DisableDbAuth,

                    site.RequiresQuestionAndAnswer,
                    site.MaxInvalidPasswordAttempts,
                    site.PasswordAttemptWindowMinutes,
                    site.MinRequiredPasswordLength,
                    site.MinReqNonAlphaChars,
                    site.DefaultEmailFromAddress,
                    site.AllowDbFallbackWithLdap,
                    site.EmailLdapDbFallback,
                    site.AllowPersistentLogin,
                    site.CaptchaOnLogin,
                    site.CaptchaOnRegistration,
                    site.SiteIsClosed,
                    site.SiteIsClosedMessage,
                    site.PrivacyPolicy,
                    site.TimeZoneId,
                    site.GoogleAnalyticsProfileId,
                    site.CompanyName,
                    site.CompanyStreetAddress,
                    site.CompanyStreetAddress2,
                    site.CompanyRegion,
                    site.CompanyLocality,
                    site.CompanyCountry,
                    site.CompanyPostalCode,
                    site.CompanyPublicEmail,
                    site.CompanyPhone,
                    site.CompanyFax,
                    site.FacebookAppId,
                    site.FacebookAppSecret,
                    site.GoogleClientId,
                    site.GoogleClientSecret,
                    site.TwitterConsumerKey,
                    site.TwitterConsumerSecret,
                    site.MicrosoftClientId,
                    site.MicrosoftClientSecret,
                    site.PreferredHostName,
                    site.SiteFolderName,
                    site.AddThisDotComUsername,
                    site.LoginInfoTop,
                    site.LoginInfoBottom,
                    site.RegistrationAgreement,
                    site.RegistrationPreamble,
                    site.SmtpServer,
                    site.SmtpPort,
                    site.SmtpUser,
                    site.SmtpPassword,
                    site.SmtpPreferredEncoding,
                    site.SmtpRequiresAuth,
                    site.SmtpUseSsl,
                    site.RequireApprovalBeforeLogin,
                    site.IsDataProtected

                    );
            }

            if (!result)
            {
                return(result);
            }

            // settings below stored as key value pairs in mp_SiteSettingsEx


            //dbSiteSettingsEx.EnsureSettings();

            //List<ExpandoSetting> expandoProperties = GetExpandoProperties(passedInSiteId); //-1 on new sites to get the default values

            // update a local data table of expando properties if the value changed and mark the row dirty
            //site.SetExpandoSettings(expandoProperties);
            // finally update the database only with properties in the table marked as dirty
            //SaveExpandoProperties(site.SiteId, site.SiteGuid, expandoProperties);

            return(result);
        }