From afba2a6f73f99408ef262a6fcc5284bbd66efdb7 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 28 Aug 2018 12:21:44 -0500 Subject: [PATCH] Add hide_username_with_complete_name conf setting - refs BT#14769 Hide the username when showing the complete name for a user --- main/inc/lib/api.lib.php | 2 +- main/install/configuration.dist.php | 4 ++++ src/Chamilo/UserBundle/Entity/User.php | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 85a45b6b0a..9b0be9a082 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1461,7 +1461,7 @@ function _api_format_user($user, $add_password = false, $loadAvatars = true) $result['complete_name'] = api_get_person_name($result['firstname'], $result['lastname']); $result['complete_name_with_username'] = $result['complete_name']; - if (!empty($user['username'])) { + if (!empty($user['username']) && !api_get_configuration_value('hide_username_with_complete_name')) { $result['complete_name_with_username'] = $result['complete_name'].' ('.$user['username'].')'; } diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 28cdf47d24..163cac9cbb 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -958,6 +958,10 @@ VALUES (2, 13, 'session_courses_read_only_mode', 'Lock Course In Session', 1, 1, ] ];*/ +// Hide the username when showing the complete name for a user. +// Example: using api_get_user_info()['complete_name_with_username'] or $user->getCompleteNameWithUsername() +//$_configuration['hide_username_with_complete_name'] = false; + // ------ Custom DB changes (keep this at the end) // Add user activation by confirmation email // This option prevents the new user to login in the platform if your account is not confirmed via email diff --git a/src/Chamilo/UserBundle/Entity/User.php b/src/Chamilo/UserBundle/Entity/User.php index 9af4398fd3..ce0f892560 100644 --- a/src/Chamilo/UserBundle/Entity/User.php +++ b/src/Chamilo/UserBundle/Entity/User.php @@ -793,6 +793,10 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser */ public function getCompleteNameWithUsername() { + if (api_get_configuration_value('hide_username_with_complete_name')) { + return $this->getCompleteName(); + } + return api_get_person_name($this->firstname, $this->lastname).' ('.$this->username.')'; }