module_settings_act_api.go 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package modules
  2. import (
  3. "golang-fave/engine/utils"
  4. "golang-fave/engine/wrapper"
  5. )
  6. func (this *Modules) RegisterAction_SettingsApi() *Action {
  7. return this.newAction(AInfo{
  8. Mount: "settings-api",
  9. WantAdmin: true,
  10. }, func(wrap *wrapper.Wrapper) {
  11. pf_xml_enabled := utils.Trim(wrap.R.FormValue("xml-enabled"))
  12. pf_xml_name := utils.Trim(wrap.R.FormValue("xml-name"))
  13. pf_xml_company := utils.Trim(wrap.R.FormValue("xml-company"))
  14. pf_xml_url := utils.Trim(wrap.R.FormValue("xml-url"))
  15. if pf_xml_enabled == "" {
  16. pf_xml_enabled = "0"
  17. }
  18. (*wrap.Config).API.XML.Enabled = utils.StrToInt(pf_xml_enabled)
  19. (*wrap.Config).API.XML.Name = pf_xml_name
  20. (*wrap.Config).API.XML.Company = pf_xml_company
  21. (*wrap.Config).API.XML.Url = pf_xml_url
  22. if err := wrap.ConfigSave(); err != nil {
  23. wrap.MsgError(err.Error())
  24. return
  25. }
  26. wrap.RecreateProductXmlFile()
  27. wrap.ResetCacheBlocks()
  28. // Reload current page
  29. wrap.Write(`window.location.reload(false);`)
  30. })
  31. }