diff --git a/src/global/global.go b/src/global/global.go
index b690295..c518d11 100644
--- a/src/global/global.go
+++ b/src/global/global.go
@@ -12,6 +12,7 @@ import (
// Global variables
var ThisSession Session
var MainConfig Config
+
const defaultConfigDir string = "default-config/"
const configDir string = "config/"
@@ -33,6 +34,7 @@ func loadConfig() Config {
fmt.Println("Loading Custom Services…")
customsvcfile := configDir + "services.yaml"
unmarshalConfig(customsvcfile, &cfg)
+ removeDisabledItems(&cfg)
return cfg
}
@@ -44,12 +46,36 @@ func unmarshalConfig(file string, cfg *Config) {
}
err2 := yaml.Unmarshal(content, &cfg)
if err2 != nil {
- fmt.Println("Error unmarshalling config :", file, " : ", err2)
+ fmt.Println("Error unmarshaling config :", file, " : ", err2)
}
}
}
-
+func removeDisabledItems(cfg *Config) {
+ // Rework this, not pretty
+ if !cfg.InMail.Enabled {
+ cfg.InMail = Service{}
+ }
+ if !cfg.OutMail.Enabled {
+ cfg.OutMail = Service{}
+ }
+ if !cfg.Calendar.Enabled {
+ cfg.Calendar = Service{}
+ }
+ if !cfg.AddressBook.Enabled {
+ cfg.AddressBook = Service{}
+ }
+ if !cfg.WebMail.Enabled {
+ cfg.WebMail = Service{}
+ }
+ new_svcs := []Service{}
+ for _,svc := range cfg.OtherServices {
+ if svc.Enabled {
+ new_svcs = append(new_svcs,svc)
+ }
+ }
+ cfg.OtherServices = new_svcs
+}
func FileExists(file string) bool {
exists := false
if _, err := os.Stat(file); err == nil {
diff --git a/src/templates/autoconfig.xml b/src/templates/autoconfig.xml
index 9320e50..a721a4b 100644
--- a/src/templates/autoconfig.xml
+++ b/src/templates/autoconfig.xml
@@ -1,50 +1,60 @@
-
- {{ range .Config.Domains }}{{ . }}
- {{ end }}
- {{ .Email }}
- {{ with .Config.InMail }}
-
- {{ .Server }}
- {{ .Port }}
- {{ .SocketType }}
- {{ . | parseUsername }}
- {{ .Authentication }}
-
- {{ end }}
- {{ with .Config.OutMail }}
-
- {{ .Server }}
- {{ .Port }}>
- {{ .SocketType }}
- {{ . | parseUsername }}
- {{ .Authentication }}
-
- {{ end }}
- {{ with .Config.AddressBook }}
-
- {{ . | parseUsername }}
- {{ .Authentication }}
- {{ .Server }}
-
+
+ {{ range .Config.Domains }}{{ . }}
+ {{ end }}
+ {{ .Email }}
+ {{ with .Config.InMail }}
+ {{ if .Enabled }}
+
+ {{ .Server }}
+ {{ .Port }}
+ {{ .SocketType }}
+ {{ . | parseUsername }}
+ {{ .Authentication }}
+
+ {{ end }}
+ {{ end }}
+ {{ with .Config.OutMail }}
+ {{ if .Enabled }}
+
+ {{ .Server }}
+ {{ .Port }}>
+ {{ .SocketType }}
+ {{ . | parseUsername }}
+ {{ .Authentication }}
+
+ {{ end }}
+ {{ end }}
+ {{ with .Config.AddressBook }}
+ {{ if .Enabled }}
+
+ {{ . | parseUsername }}
+ {{ .Authentication }}
+ {{ .Server }}
+
+ {{ end }}
{{ end }}
{{ with .Config.Calendar }}
-
- {{ . | parseUsername }}
- {{ .Authentication }}
- {{ .Server }}
-
+ {{ if .Enabled }}
+
+ {{ . | parseUsername }}
+ {{ .Authentication }}
+ {{ .Server }}
+
+ {{ end }}
{{ end }}
{{ with .Config.WebMail }}
-
-
-
- {{ . | parseUsername }}
-
-
-
-
-
+ {{ if .Enabled }}
+
+
+
+ {{ . | parseUsername }}
+
+
+
+
+
+ {{ end }}
{{ end }}
diff --git a/src/templates/autodiscover.xml b/src/templates/autodiscover.xml
index b024b74..8669b2b 100644
--- a/src/templates/autodiscover.xml
+++ b/src/templates/autodiscover.xml
@@ -5,30 +5,34 @@
email
settings
{{ with .Config.InMail }}
-
- {{ .Type }}
- {{ .Server }}
- {{ .Port }}
- {{ .UsernameIsFQDN | onoff }}
- {{ . | parseUsername }}
- {{ .SPA | onoff }}
- {{ if eq .SocketType "SSL" }}on{{ else }}off{{ end }}
- {{ not .NoAuthRequired | onoff }}
-
+ {{ if .Enabled }}
+
+ {{ .Type }}
+ {{ .Server }}
+ {{ .Port }}
+ {{ .UsernameIsFQDN | onoff }}
+ {{ . | parseUsername }}
+ {{ .SPA | onoff }}
+ {{ if eq .SocketType "SSL" }}on{{ else }}off{{ end }}
+ {{ not .NoAuthRequired | onoff }}
+
+ {{ end }}
{{ end }}
{{ with .Config.OutMail }}
-
- {{ .Type }}
- {{ .Server }}
- {{ .Port }}
- {{ .UsernameIsFQDN | onoff }}
- {{ . | parseUsername }}
- {{ .SPA | onoff }}
- {{ .SocketType }}
- {{ not .NoAuthRequired | onoff }}
- {{ .POPAuth | onoff }}
- {{ .SMTPLast | onoff }}
-
+ {{ if .Enabled }}
+
+ {{ .Type }}
+ {{ .Server }}
+ {{ .Port }}
+ {{ .UsernameIsFQDN | onoff }}
+ {{ . | parseUsername }}
+ {{ .SPA | onoff }}
+ {{ .SocketType }}
+ {{ not .NoAuthRequired | onoff }}
+ {{ .POPAuth | onoff }}
+ {{ .SMTPLast | onoff }}
+
+ {{ end }}
{{ end }}
diff --git a/src/web/responses/responses.go b/src/web/responses/responses.go
index 1e37485..754aa6e 100644
--- a/src/web/responses/responses.go
+++ b/src/web/responses/responses.go
@@ -81,7 +81,7 @@ func OurConfig() string {
}
func parseUsername(svc Service) string {
if email == "" {
- return ""
+ return "not-provided"
}
if svc.UsernameIsFQDN && !svc.RequireLocalDomain{
return email