module_settings_act_general.go 902 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package modules
  2. import (
  3. "golang-fave/engine/wrapper"
  4. "golang-fave/utils"
  5. )
  6. func (this *Modules) RegisterAction_SettingsGeneral() *Action {
  7. return this.newAction(AInfo{
  8. WantDB: true,
  9. Mount: "settings-general",
  10. WantAdmin: true,
  11. }, func(wrap *wrapper.Wrapper) {
  12. pf_module_at_home := utils.Trim(wrap.R.FormValue("module-at-home"))
  13. if !utils.IsNumeric(pf_module_at_home) {
  14. wrap.MsgError(`Must be integer number`)
  15. return
  16. }
  17. pfi_module_at_home := utils.StrToInt(pf_module_at_home)
  18. // Correct values
  19. if pfi_module_at_home < 0 {
  20. pfi_module_at_home = 0
  21. }
  22. if pfi_module_at_home > 2 {
  23. pfi_module_at_home = 2
  24. }
  25. (*wrap.Config).Engine.MainModule = pfi_module_at_home
  26. if err := wrap.ConfigSave(); err != nil {
  27. wrap.MsgError(err.Error())
  28. return
  29. }
  30. wrap.ResetCacheBlocks()
  31. // Reload current page
  32. wrap.Write(`window.location.reload(false);`)
  33. })
  34. }