11using BlogEngine . Core . Data . Models ;
2+ using BlogEngine . Core . Data . ViewModels ;
23using BlogEngine . Core . Data . Contracts ;
34
45namespace BlogEngine . Core . Data
@@ -12,122 +13,13 @@ public class SettingsRepository : ISettingsRepository
1213 /// Get all settings
1314 /// </summary>
1415 /// <returns>Settings object</returns>
15- public Settings Get ( )
16+ public SettingsVM Get ( )
1617 {
17- if ( ! Security . IsAuthorizedTo ( Rights . AccessAdminSettingsPages ) )
18- throw new System . UnauthorizedAccessException ( ) ;
19-
20- var ns = new Settings ( ) ;
21- var bs = BlogSettings . Instance ;
22-
23- // basic
24- ns . Name = bs . Name ;
25- ns . Description = bs . Description ;
26- ns . PostsPerPage = bs . PostsPerPage ;
27- ns . ThemeCookieName = bs . ThemeCookieName ;
28- ns . UseBlogNameInPageTitles = bs . UseBlogNameInPageTitles ;
29- ns . EnableRelatedPosts = bs . EnableRelatedPosts ;
30- ns . EnableRating = bs . EnableRating ;
31- ns . ShowDescriptionInPostList = bs . ShowDescriptionInPostList ;
32- ns . DescriptionCharacters = bs . DescriptionCharacters ;
33- ns . ShowDescriptionInPostListForPostsByTagOrCategory = bs . ShowDescriptionInPostListForPostsByTagOrCategory ;
34- ns . DescriptionCharactersForPostsByTagOrCategory = bs . DescriptionCharactersForPostsByTagOrCategory ;
35- ns . TimeStampPostLinks = bs . TimeStampPostLinks ;
36- ns . ShowPostNavigation = bs . ShowPostNavigation ;
37- ns . Culture = bs . Culture ;
38- ns . Timezone = bs . Timezone ;
39- ns . RemoveExtensionsFromUrls = bs . RemoveExtensionsFromUrls ;
40- ns . RedirectToRemoveFileExtension = bs . RedirectToRemoveFileExtension ;
41- ns . DesktopTheme = bs . Theme ;
42-
43- // advanced
44- ns . HandleWwwSubdomain = bs . HandleWwwSubdomain ;
45- ns . EnableHttpCompression = bs . EnableHttpCompression ;
46- ns . CompressWebResource = bs . CompressWebResource ;
47- ns . EnableOpenSearch = bs . EnableOpenSearch ;
48- ns . RequireSslForMetaWeblogApi = bs . RequireSslMetaWeblogApi ;
49-
50- ns . EnablePasswordReset = bs . EnablePasswordReset ;
51- ns . EnableSelfRegistration = bs . EnableSelfRegistration ;
52- ns . CreateBlogOnSelfRegistration = bs . CreateBlogOnSelfRegistration ;
53- ns . AllowServerToDownloadRemoteFiles = bs . AllowServerToDownloadRemoteFiles ;
54- ns . RemoteFileDownloadTimeout = bs . RemoteFileDownloadTimeout ;
55- ns . RemoteMaxFileSize = bs . RemoteMaxFileSize ;
56- ns . SelfRegistrationInitialRole = bs . SelfRegistrationInitialRole ;
57- if ( string . IsNullOrEmpty ( ns . SelfRegistrationInitialRole ) )
58- {
59- // set to default editor role if not set in settings
60- ns . SelfRegistrationInitialRole = BlogConfig . EditorsRole ;
61- }
62-
63- // feed
64- ns . AuthorName = bs . AuthorName ;
65- ns . FeedAuthor = bs . FeedAuthor ;
66- ns . Endorsement = bs . Endorsement ;
67- ns . AlternateFeedUrl = bs . AlternateFeedUrl ;
68- ns . Language = bs . Language ;
69- ns . PostsPerFeed = bs . PostsPerFeed ;
70- ns . EnableEnclosures = bs . EnableEnclosures ;
71- ns . SyndicationFormat = bs . SyndicationFormat ;
72- ns . EnableTagExport = bs . EnableTagExport ;
73-
74- // email
75- ns . Email = bs . Email ;
76- ns . SmtpServer = bs . SmtpServer ;
77- ns . SmtpServerPort = bs . SmtpServerPort ;
78- ns . SmtpUserName = bs . SmtpUserName ;
79- ns . SmtpPassword = bs . SmtpPassword ;
80- ns . EmailSubjectPrefix = bs . EmailSubjectPrefix ;
81- ns . EnableSsl = bs . EnableSsl ;
82- ns . SendMailOnComment = bs . SendMailOnComment ;
18+ var vm = new SettingsVM ( ) ;
8319
84- // controls
85- ns . SearchButtonText = bs . SearchButtonText ;
86- ns . SearchCommentLabelText = bs . SearchCommentLabelText ;
87- ns . SearchDefaultText = bs . SearchDefaultText ;
88- ns . EnableCommentSearch = bs . EnableCommentSearch ;
89- ns . ShowIncludeCommentsOption = bs . ShowIncludeCommentsOption ;
90- ns . ContactFormMessage = bs . ContactFormMessage ;
91- ns . ContactThankMessage = bs . ContactThankMessage ;
92- ns . ContactErrorMessage = bs . ContactErrorMessage ;
93- ns . EnableContactAttachments = bs . EnableContactAttachments ;
94- ns . EnableRecaptchaOnContactForm = bs . EnableRecaptchaOnContactForm ;
95- ns . ErrorTitle = bs . ErrorTitle ;
96- ns . ErrorText = bs . ErrorText ;
97-
98- // custom code
99- ns . HtmlHeader = bs . HtmlHeader ;
100- ns . TrackingScript = bs . TrackingScript ;
20+ vm . Settings = GetSettings ( ) ;
10121
102- // comments
103- ns . DaysCommentsAreEnabled = bs . DaysCommentsAreEnabled ;
104- ns . IsCommentsEnabled = bs . IsCommentsEnabled ;
105- ns . EnableCommentsModeration = bs . EnableCommentsModeration ;
106- ns . IsCommentNestingEnabled = bs . IsCommentNestingEnabled ;
107- ns . Avatar = bs . Avatar ;
108- ns . EnablePingBackSend = bs . EnablePingBackSend ;
109- ns . EnablePingBackReceive = bs . EnablePingBackReceive ;
110- ns . EnableTrackBackSend = bs . EnableTrackBackSend ;
111- ns . EnableTrackBackReceive = bs . EnableTrackBackReceive ;
112- ns . CommentsPerPage = bs . CommentsPerPage ;
113- ns . EnableCountryInComments = bs . EnableCountryInComments ;
114- ns . EnableWebsiteInComments = bs . EnableWebsiteInComments ;
115- ns . ShowLivePreview = bs . ShowLivePreview ;
116-
117- ns . CommentProvider = bs . CommentProvider ;
118- ns . DisqusDevMode = bs . DisqusDevMode ;
119- ns . DisqusAddCommentsToPages = bs . DisqusAddCommentsToPages ;
120- ns . DisqusWebsiteName = bs . DisqusWebsiteName ;
121-
122- // custom filters
123- ns . CommentWhiteListCount = bs . CommentWhiteListCount ;
124- ns . CommentBlackListCount = bs . CommentBlackListCount ;
125- ns . AddIpToWhitelistFilterOnApproval = bs . AddIpToWhitelistFilterOnApproval ;
126- ns . TrustAuthenticatedUsers = bs . TrustAuthenticatedUsers ;
127- ns . BlockAuthorOnCommentDelete = bs . BlockAuthorOnCommentDelete ;
128- ns . AddIpToBlacklistFilterOnRejection = bs . AddIpToBlacklistFilterOnRejection ;
129-
130- return ns ;
22+ return vm ;
13123 }
13224
13325 /// <summary>
@@ -157,6 +49,7 @@ public bool Update(Settings ns)
15749 bs . ShowPostNavigation = ns . ShowPostNavigation ;
15850 bs . Culture = ns . Culture ;
15951 bs . Timezone = ns . Timezone ;
52+ bs . TimeZoneId = ns . TimeZoneId ;
16053 bs . RemoveExtensionsFromUrls = ns . RemoveExtensionsFromUrls ;
16154 bs . RedirectToRemoveFileExtension = ns . RedirectToRemoveFileExtension ;
16255 bs . Theme = ns . DesktopTheme ;
@@ -246,5 +139,124 @@ public bool Update(Settings ns)
246139 bs . Save ( ) ;
247140 return true ;
248141 }
142+
143+ private Settings GetSettings ( )
144+ {
145+ if ( ! Security . IsAuthorizedTo ( Rights . AccessAdminSettingsPages ) )
146+ throw new System . UnauthorizedAccessException ( ) ;
147+
148+ var ns = new Settings ( ) ;
149+ var bs = BlogSettings . Instance ;
150+
151+ // basic
152+ ns . Name = bs . Name ;
153+ ns . Description = bs . Description ;
154+ ns . PostsPerPage = bs . PostsPerPage ;
155+ ns . ThemeCookieName = bs . ThemeCookieName ;
156+ ns . UseBlogNameInPageTitles = bs . UseBlogNameInPageTitles ;
157+ ns . EnableRelatedPosts = bs . EnableRelatedPosts ;
158+ ns . EnableRating = bs . EnableRating ;
159+ ns . ShowDescriptionInPostList = bs . ShowDescriptionInPostList ;
160+ ns . DescriptionCharacters = bs . DescriptionCharacters ;
161+ ns . ShowDescriptionInPostListForPostsByTagOrCategory = bs . ShowDescriptionInPostListForPostsByTagOrCategory ;
162+ ns . DescriptionCharactersForPostsByTagOrCategory = bs . DescriptionCharactersForPostsByTagOrCategory ;
163+ ns . TimeStampPostLinks = bs . TimeStampPostLinks ;
164+ ns . ShowPostNavigation = bs . ShowPostNavigation ;
165+ ns . Culture = bs . Culture ;
166+ ns . Timezone = bs . Timezone ;
167+ ns . TimeZoneId = bs . TimeZoneId == null ? "UTC" : bs . TimeZoneId ;
168+ ns . RemoveExtensionsFromUrls = bs . RemoveExtensionsFromUrls ;
169+ ns . RedirectToRemoveFileExtension = bs . RedirectToRemoveFileExtension ;
170+ ns . DesktopTheme = bs . Theme ;
171+
172+ // advanced
173+ ns . HandleWwwSubdomain = bs . HandleWwwSubdomain ;
174+ ns . EnableHttpCompression = bs . EnableHttpCompression ;
175+ ns . CompressWebResource = bs . CompressWebResource ;
176+ ns . EnableOpenSearch = bs . EnableOpenSearch ;
177+ ns . RequireSslForMetaWeblogApi = bs . RequireSslMetaWeblogApi ;
178+
179+ ns . EnablePasswordReset = bs . EnablePasswordReset ;
180+ ns . EnableSelfRegistration = bs . EnableSelfRegistration ;
181+ ns . CreateBlogOnSelfRegistration = bs . CreateBlogOnSelfRegistration ;
182+ ns . AllowServerToDownloadRemoteFiles = bs . AllowServerToDownloadRemoteFiles ;
183+ ns . RemoteFileDownloadTimeout = bs . RemoteFileDownloadTimeout ;
184+ ns . RemoteMaxFileSize = bs . RemoteMaxFileSize ;
185+ ns . SelfRegistrationInitialRole = bs . SelfRegistrationInitialRole ;
186+ if ( string . IsNullOrEmpty ( ns . SelfRegistrationInitialRole ) )
187+ {
188+ // set to default editor role if not set in settings
189+ ns . SelfRegistrationInitialRole = BlogConfig . EditorsRole ;
190+ }
191+
192+ // feed
193+ ns . AuthorName = bs . AuthorName ;
194+ ns . FeedAuthor = bs . FeedAuthor ;
195+ ns . Endorsement = bs . Endorsement ;
196+ ns . AlternateFeedUrl = bs . AlternateFeedUrl ;
197+ ns . Language = bs . Language ;
198+ ns . PostsPerFeed = bs . PostsPerFeed ;
199+ ns . EnableEnclosures = bs . EnableEnclosures ;
200+ ns . SyndicationFormat = bs . SyndicationFormat ;
201+ ns . EnableTagExport = bs . EnableTagExport ;
202+
203+ // email
204+ ns . Email = bs . Email ;
205+ ns . SmtpServer = bs . SmtpServer ;
206+ ns . SmtpServerPort = bs . SmtpServerPort ;
207+ ns . SmtpUserName = bs . SmtpUserName ;
208+ ns . SmtpPassword = bs . SmtpPassword ;
209+ ns . EmailSubjectPrefix = bs . EmailSubjectPrefix ;
210+ ns . EnableSsl = bs . EnableSsl ;
211+ ns . SendMailOnComment = bs . SendMailOnComment ;
212+
213+ // controls
214+ ns . SearchButtonText = bs . SearchButtonText ;
215+ ns . SearchCommentLabelText = bs . SearchCommentLabelText ;
216+ ns . SearchDefaultText = bs . SearchDefaultText ;
217+ ns . EnableCommentSearch = bs . EnableCommentSearch ;
218+ ns . ShowIncludeCommentsOption = bs . ShowIncludeCommentsOption ;
219+ ns . ContactFormMessage = bs . ContactFormMessage ;
220+ ns . ContactThankMessage = bs . ContactThankMessage ;
221+ ns . ContactErrorMessage = bs . ContactErrorMessage ;
222+ ns . EnableContactAttachments = bs . EnableContactAttachments ;
223+ ns . EnableRecaptchaOnContactForm = bs . EnableRecaptchaOnContactForm ;
224+ ns . ErrorTitle = bs . ErrorTitle ;
225+ ns . ErrorText = bs . ErrorText ;
226+
227+ // custom code
228+ ns . HtmlHeader = bs . HtmlHeader ;
229+ ns . TrackingScript = bs . TrackingScript ;
230+
231+ // comments
232+ ns . DaysCommentsAreEnabled = bs . DaysCommentsAreEnabled ;
233+ ns . IsCommentsEnabled = bs . IsCommentsEnabled ;
234+ ns . EnableCommentsModeration = bs . EnableCommentsModeration ;
235+ ns . IsCommentNestingEnabled = bs . IsCommentNestingEnabled ;
236+ ns . Avatar = bs . Avatar ;
237+ ns . EnablePingBackSend = bs . EnablePingBackSend ;
238+ ns . EnablePingBackReceive = bs . EnablePingBackReceive ;
239+ ns . EnableTrackBackSend = bs . EnableTrackBackSend ;
240+ ns . EnableTrackBackReceive = bs . EnableTrackBackReceive ;
241+ ns . CommentsPerPage = bs . CommentsPerPage ;
242+ ns . EnableCountryInComments = bs . EnableCountryInComments ;
243+ ns . EnableWebsiteInComments = bs . EnableWebsiteInComments ;
244+ ns . ShowLivePreview = bs . ShowLivePreview ;
245+
246+ ns . CommentProvider = bs . CommentProvider ;
247+ ns . DisqusDevMode = bs . DisqusDevMode ;
248+ ns . DisqusAddCommentsToPages = bs . DisqusAddCommentsToPages ;
249+ ns . DisqusWebsiteName = bs . DisqusWebsiteName ;
250+
251+ // custom filters
252+ ns . CommentWhiteListCount = bs . CommentWhiteListCount ;
253+ ns . CommentBlackListCount = bs . CommentBlackListCount ;
254+ ns . AddIpToWhitelistFilterOnApproval = bs . AddIpToWhitelistFilterOnApproval ;
255+ ns . TrustAuthenticatedUsers = bs . TrustAuthenticatedUsers ;
256+ ns . BlockAuthorOnCommentDelete = bs . BlockAuthorOnCommentDelete ;
257+ ns . AddIpToBlacklistFilterOnRejection = bs . AddIpToBlacklistFilterOnRejection ;
258+
259+ return ns ;
260+ }
249261 }
250262}
0 commit comments