module_settings_act_api.go 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. WantDB: true,
  9. Mount: "settings-api",
  10. WantAdmin: true,
  11. }, func(wrap *wrapper.Wrapper) {
  12. pf_xml_enabled := utils.Trim(wrap.R.FormValue("xml-enabled"))
  13. pf_xml_name := utils.Trim(wrap.R.FormValue("xml-name"))
  14. pf_xml_company := utils.Trim(wrap.R.FormValue("xml-company"))
  15. pf_xml_url := utils.Trim(wrap.R.FormValue("xml-url"))
  16. if pf_xml_enabled == "" {
  17. pf_xml_enabled = "0"
  18. }
  19. (*wrap.Config).API.XML.Enabled = utils.StrToInt(pf_xml_enabled)
  20. (*wrap.Config).API.XML.Name = pf_xml_name
  21. (*wrap.Config).API.XML.Company = pf_xml_company
  22. (*wrap.Config).API.XML.Url = pf_xml_url
  23. if err := wrap.ConfigSave(); err != nil {
  24. wrap.MsgError(err.Error())
  25. return
  26. }
  27. wrap.RecreateProductXmlFile()
  28. wrap.ResetCacheBlocks()
  29. // Reload current page
  30. wrap.Write(`window.location.reload(false);`)
  31. })
  32. }