MCPcopy
hub / github.com/writefreely/writefreely / handleAdminUpdateConfig

Function handleAdminUpdateConfig

admin.go:571–606  ·  view source on GitHub ↗
(apper Apper, u *User, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

569}
570
571func handleAdminUpdateConfig(apper Apper, u *User, w http.ResponseWriter, r *http.Request) error {
572 apper.App().cfg.App.SiteName = r.FormValue("site_name")
573 apper.App().cfg.App.SiteDesc = r.FormValue("site_desc")
574 apper.App().cfg.App.Landing = r.FormValue("landing")
575 apper.App().cfg.App.OpenRegistration = r.FormValue("open_registration") == "on"
576 apper.App().cfg.App.OpenDeletion = r.FormValue("open_deletion") == "on"
577 mul, err := strconv.Atoi(r.FormValue("min_username_len"))
578 if err == nil {
579 apper.App().cfg.App.MinUsernameLen = mul
580 }
581 mb, err := strconv.Atoi(r.FormValue("max_blogs"))
582 if err == nil {
583 apper.App().cfg.App.MaxBlogs = mb
584 }
585 apper.App().cfg.App.Federation = r.FormValue("federation") == "on"
586 apper.App().cfg.App.PublicStats = r.FormValue("public_stats") == "on"
587 apper.App().cfg.App.Monetization = r.FormValue("monetization") == "on"
588 apper.App().cfg.App.Private = r.FormValue("private") == "on"
589 apper.App().cfg.App.LocalTimeline = r.FormValue("local_timeline") == "on"
590 if apper.App().cfg.App.LocalTimeline && apper.App().timeline == nil {
591 log.Info("Initializing local timeline...")
592 initLocalTimeline(apper.App())
593 }
594 apper.App().cfg.App.UserInvites = r.FormValue("user_invites")
595 if apper.App().cfg.App.UserInvites == "none" {
596 apper.App().cfg.App.UserInvites = ""
597 }
598 apper.App().cfg.App.DefaultVisibility = r.FormValue("default_visibility")
599
600 m := "?cm=Configuration+saved."
601 err = apper.SaveConfig(apper.App().cfg)
602 if err != nil {
603 m = "?cm=" + err.Error()
604 }
605 return impart.HTTPError{http.StatusFound, "/admin/settings" + m + "#config"}
606}
607
608func updateAppStats() {
609 sysStatus.Uptime = appstats.TimeSincePro(appStartTime)

Callers

nothing calls this directly

Calls 3

initLocalTimelineFunction · 0.85
AppMethod · 0.65
SaveConfigMethod · 0.65

Tested by

no test coverage detected