Browse Source

Enable/disable option for blog and shop modules in general settings

Vova Tkach 5 years ago
parent
commit
f165915d80

+ 9 - 0
engine/config/config.go

@@ -72,6 +72,12 @@ type Config struct {
 		Login    string
 		Login    string
 		Password string
 		Password string
 	}
 	}
+	Modules struct {
+		Enabled struct {
+			Blog int
+			Shop int
+		}
+	}
 }
 }
 
 
 func ConfigNew() *Config {
 func ConfigNew() *Config {
@@ -142,6 +148,9 @@ func (this *Config) configDefault() {
 	this.SMTP.Port = 587
 	this.SMTP.Port = 587
 	this.SMTP.Login = ""
 	this.SMTP.Login = ""
 	this.SMTP.Password = ""
 	this.SMTP.Password = ""
+
+	this.Modules.Enabled.Blog = 1
+	this.Modules.Enabled.Shop = 1
 }
 }
 
 
 func (this *Config) ConfigRead(file string) error {
 func (this *Config) ConfigRead(file string) error {

+ 14 - 0
engine/modules/module_settings.go

@@ -86,6 +86,20 @@ func (this *Modules) RegisterModule_Settings() *Module {
 					Value:   utils.IntToStr((*wrap.Config).Engine.Maintenance),
 					Value:   utils.IntToStr((*wrap.Config).Engine.Maintenance),
 					Hint:    "Close web site for maintenance",
 					Hint:    "Close web site for maintenance",
 				},
 				},
+				{
+					Kind:    builder.DFKCheckBox,
+					Caption: "Blog is enabled",
+					Name:    "mod-enabled-blog",
+					Value:   utils.IntToStr((*wrap.Config).Modules.Enabled.Blog),
+					Hint:    "Module can be enabled or fully disabled",
+				},
+				{
+					Kind:    builder.DFKCheckBox,
+					Caption: "Shop is enabled",
+					Name:    "mod-enabled-shop",
+					Value:   utils.IntToStr((*wrap.Config).Modules.Enabled.Shop),
+					Hint:    "Module can be enabled or fully disabled",
+				},
 				{
 				{
 					Kind:   builder.DFKSubmit,
 					Kind:   builder.DFKSubmit,
 					Value:  "Save",
 					Value:  "Save",

+ 36 - 0
engine/modules/module_settings_act_general.go

@@ -12,6 +12,8 @@ func (this *Modules) RegisterAction_SettingsGeneral() *Action {
 	}, func(wrap *wrapper.Wrapper) {
 	}, func(wrap *wrapper.Wrapper) {
 		pf_module_at_home := utils.Trim(wrap.R.FormValue("module-at-home"))
 		pf_module_at_home := utils.Trim(wrap.R.FormValue("module-at-home"))
 		pf_maintenance := utils.Trim(wrap.R.FormValue("maintenance"))
 		pf_maintenance := utils.Trim(wrap.R.FormValue("maintenance"))
+		pf_mod_enabled_blog := utils.Trim(wrap.R.FormValue("mod-enabled-blog"))
+		pf_mod_enabled_shop := utils.Trim(wrap.R.FormValue("mod-enabled-shop"))
 
 
 		if !utils.IsNumeric(pf_module_at_home) {
 		if !utils.IsNumeric(pf_module_at_home) {
 			wrap.MsgError(`Must be integer number`)
 			wrap.MsgError(`Must be integer number`)
@@ -26,8 +28,26 @@ func (this *Modules) RegisterAction_SettingsGeneral() *Action {
 			return
 			return
 		}
 		}
 
 
+		if pf_mod_enabled_blog == "" {
+			pf_mod_enabled_blog = "0"
+		}
+		if !utils.IsNumeric(pf_mod_enabled_blog) {
+			wrap.MsgError(`Must be integer number`)
+			return
+		}
+
+		if pf_mod_enabled_shop == "" {
+			pf_mod_enabled_shop = "0"
+		}
+		if !utils.IsNumeric(pf_mod_enabled_shop) {
+			wrap.MsgError(`Must be integer number`)
+			return
+		}
+
 		pfi_module_at_home := utils.StrToInt(pf_module_at_home)
 		pfi_module_at_home := utils.StrToInt(pf_module_at_home)
 		pfi_maintenance := utils.StrToInt(pf_maintenance)
 		pfi_maintenance := utils.StrToInt(pf_maintenance)
+		pfi_mod_enabled_blog := utils.StrToInt(pf_mod_enabled_blog)
+		pfi_mod_enabled_shop := utils.StrToInt(pf_mod_enabled_shop)
 
 
 		// Correct values
 		// Correct values
 		if pfi_module_at_home < 0 {
 		if pfi_module_at_home < 0 {
@@ -44,8 +64,24 @@ func (this *Modules) RegisterAction_SettingsGeneral() *Action {
 			pfi_maintenance = 1
 			pfi_maintenance = 1
 		}
 		}
 
 
+		if pfi_mod_enabled_blog < 0 {
+			pfi_mod_enabled_blog = 0
+		}
+		if pfi_mod_enabled_blog > 1 {
+			pfi_mod_enabled_blog = 1
+		}
+
+		if pfi_mod_enabled_shop < 0 {
+			pfi_mod_enabled_shop = 0
+		}
+		if pfi_mod_enabled_shop > 1 {
+			pfi_mod_enabled_shop = 1
+		}
+
 		(*wrap.Config).Engine.MainModule = pfi_module_at_home
 		(*wrap.Config).Engine.MainModule = pfi_module_at_home
 		(*wrap.Config).Engine.Maintenance = pfi_maintenance
 		(*wrap.Config).Engine.Maintenance = pfi_maintenance
+		(*wrap.Config).Modules.Enabled.Blog = pfi_mod_enabled_blog
+		(*wrap.Config).Modules.Enabled.Shop = pfi_mod_enabled_shop
 
 
 		if err := wrap.ConfigSave(); err != nil {
 		if err := wrap.ConfigSave(); err != nil {
 			wrap.MsgError(err.Error())
 			wrap.MsgError(err.Error())