From 0a24f5cac8f131d84578b0c692ee2fe81a89fba4 Mon Sep 17 00:00:00 2001
From: EnricoFerro <enrico.ferro@dncsrl.com>
Date: Fri, 24 Aug 2018 07:00:22 +0200
Subject: [PATCH] Disable 'May Import Local Repository' when is disabled by
 setting (Issue #4779) (#4780)

---
 modules/templates/helper.go    | 3 +++
 templates/admin/user/edit.tmpl | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index c3d9e8fec2..7ee68c833e 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -165,6 +165,9 @@ func NewFuncMap() []template.FuncMap {
 		"DisableGitHooks": func() bool {
 			return setting.DisableGitHooks
 		},
+		"DisableImportLocal": func() bool {
+			return !setting.ImportLocalPaths
+		},
 		"TrN": TrN,
 		"Dict": func(values ...interface{}) (map[string]interface{}, error) {
 			if len(values)%2 != 0 {
diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl
index ae7cb56616..b2ec622ca2 100644
--- a/templates/admin/user/edit.tmpl
+++ b/templates/admin/user/edit.tmpl
@@ -92,7 +92,7 @@
 				<div class="inline field">
 					<div class="ui checkbox">
 						<label><strong>{{.i18n.Tr "admin.users.allow_import_local"}}</strong></label>
-						<input name="allow_import_local" type="checkbox" {{if .User.CanImportLocal}}checked{{end}}>
+						<input name="allow_import_local" type="checkbox" {{if .User.CanImportLocal}}checked{{end}} {{if DisableImportLocal}}disabled{{end}}>
 					</div>
 				</div>
 				{{if not .DisableRegularOrgCreation}}