From 4508380cf7937aef0bf6f99fe3eefb6c530e38e3 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 8 May 2019 10:41:35 +0200 Subject: Show full name if DefaultShowFullName setting activated (#6710) Adds a new key DEFAULT_SHOW_FULL_NAME (default false) to the [ui] section. If enabled the full name will be shown (unless it's empty, then the default username will be used) --- models/user.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'models/user.go') diff --git a/models/user.go b/models/user.go index 04fe36ffa0..a51f52afb9 100644 --- a/models/user.go +++ b/models/user.go @@ -661,6 +661,16 @@ func (u *User) DisplayName() string { return u.Name } +// GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set, +// returns username otherwise. +func (u *User) GetDisplayName() string { + trimmed := strings.TrimSpace(u.FullName) + if len(trimmed) > 0 && setting.UI.DefaultShowFullName { + return trimmed + } + return u.Name +} + func gitSafeName(name string) string { return strings.TrimSpace(strings.NewReplacer("\n", "", "<", "", ">", "").Replace(name)) } -- cgit v1.2.3