Skip to content
Permalink
Browse files

Add hide_username_with_complete_name conf setting - refs BT#14769

Hide the username when showing the complete name for a user
  • Loading branch information...
AngelFQC committed Aug 28, 2018
1 parent 50a817f commit afba2a6f73f99408ef262a6fcc5284bbd66efdb7
Showing with 9 additions and 1 deletion.
  1. +1 −1 main/inc/lib/api.lib.php
  2. +4 −0 main/install/configuration.dist.php
  3. +4 −0 src/Chamilo/UserBundle/Entity/User.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'].')';
}
@@ -958,6 +958,10 @@
]
];*/
// 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
@@ -793,6 +793,10 @@ function($entry) use ($idsToFilter) {
*/
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.')';
}

3 comments on commit afba2a6

@jmontoyaa

This comment has been minimized.

Copy link
Member

replied Aug 29, 2018

Hello,
Two things:

  1. api_* calls should not be added inside the identity, better to pass as a parameter example:

function getCompleteNameWithUsername($hideUserName = false)

  1. Please add this setting in Chamilo as a setting in master see the wiki:

https://github.com/chamilo/chamilo-lms/wiki/Add-a-new-Chamilo-setting

@AngelFQC

This comment has been minimized.

Copy link
Member Author

replied Aug 29, 2018

Hello

  • Yes, I know 😅, but I saw the api_get_person_name function and I thought that it could also be an exception to avoid repeating the call to api_get_configuration_value
  • I will
@AngelFQC

This comment has been minimized.

Copy link
Member Author

replied Aug 29, 2018

Hi @jmontoyaa I added the code for this setting and 7b6f760 to master. And I sent a PR #2650 to avoid user api_* in User entity.

Please sign in to comment.
You can’t perform that action at this time.