Merge pull request #2650 from AngelFQC/person_name

Move methods to get user complete name to UserManager
pull/2715/head
Julio Montoya 6 years ago committed by GitHub
commit 41deee8e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      main/admin/add_drh_to_user.php
  2. 2
      main/admin/course_add.php
  3. 2
      main/admin/course_edit.php
  4. 2
      main/admin/teachers_time_by_session_report.php
  5. 2
      main/admin/user_information.php
  6. 2
      main/admin/user_linking_requests.php
  7. 2
      main/auth/courses_controller.php
  8. 2
      main/auth/hrm_courses.php
  9. 12
      main/badge/assign.php
  10. 4
      main/badge/issued.php
  11. 6
      main/badge/issued_all.php
  12. 2
      main/course_info/about.php
  13. 6
      main/cron/course_finished.php
  14. 2
      main/forum/forumfunction.inc.php
  15. 2
      main/inc/ajax/message.ajax.php
  16. 2
      main/inc/ajax/session.ajax.php
  17. 4
      main/inc/ajax/user_manager.ajax.php
  18. 6
      main/inc/lib/CourseChatUtils.php
  19. 4
      main/inc/lib/formvalidator/Element/UserAvatar.php
  20. 2
      main/inc/lib/login.lib.php
  21. 2
      main/inc/lib/myspace.lib.php
  22. 2
      main/inc/lib/search/tool_processors/quiz_processor.class.php
  23. 2
      main/inc/lib/sessionmanager.lib.php
  24. 4
      main/inc/lib/template.lib.php
  25. 23
      main/inc/lib/usermanager.lib.php
  26. 6
      main/inc/lib/webservices/Rest.php
  27. 2
      main/mySpace/works_in_session_report.php
  28. 2
      main/session/about.php
  29. 2
      main/session/resume_session.php
  30. 2
      main/session/session_course_user.php
  31. 2
      main/template/default/gamification/my_progress.html.twig
  32. 2
      main/template/default/session/about.html.twig
  33. 2
      plugin/bbb/admin.php
  34. 10
      plugin/buycourses/src/buy_course_plugin.class.php
  35. 2
      plugin/buycourses/src/buycourses.ajax.php
  36. 6
      plugin/buycourses/src/configure_course.php
  37. 2
      plugin/buycourses/src/service_process.php
  38. 2
      plugin/buycourses/src/services_add.php
  39. 2
      plugin/buycourses/src/services_edit.php
  40. 2
      plugin/ims_lti/form.php
  41. 1
      src/CoreBundle/Twig/Extension/ChamiloExtension.php
  42. 28
      src/UserBundle/Entity/User.php

@ -38,7 +38,7 @@ foreach ($subscribedUsers as $subscribedUser) {
continue;
}
$hrmOptions[$hrm->getId()] = $hrm->getCompleteNameWithUsername();
$hrmOptions[$hrm->getId()] = UserManager::formatUserFullName($hrm, true);
}
$form = new FormValidator('assign_hrm');
@ -89,7 +89,7 @@ if ($form->validate()) {
$interbreadcrumb[] = ['name' => get_lang('PlatformAdmin'), 'url' => 'index.php'];
$interbreadcrumb[] = ['name' => get_lang('UserList'), 'url' => 'user_list.php'];
$interbreadcrumb[] = ['name' => $user->getCompleteName(), 'url' => 'user_information.php?user_id='.$user->getId()];
$interbreadcrumb[] = ['name' => UserManager::formatUserFullName($user), 'url' => 'user_information.php?user_id='.$user->getId()];
$toolName = get_lang('AssignHrmToUser');

@ -103,7 +103,7 @@ $currentTeacher = api_get_user_entity(api_get_user_id());
$form->addSelectAjax(
'course_teachers',
get_lang('CourseTeachers'),
[$currentTeacher->getId() => $currentTeacher->getCompleteNameWithUsername()],
[$currentTeacher->getId() => UserManager::formatUserFullName($currentTeacher, true)],
[
'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=teacher_to_basis_course',
'id' => 'course_teachers',

@ -189,7 +189,7 @@ $courseTeacherNames = [];
foreach ($course_teachers as $courseTeacherId) {
/** @var User $courseTeacher */
$courseTeacher = UserManager::getRepository()->find($courseTeacherId);
$courseTeacherNames[$courseTeacher->getUserId()] = $courseTeacher->getCompleteNameWithUsername();
$courseTeacherNames[$courseTeacher->getUserId()] = UserManager::formatUserFullName($courseTeacher, true);
}
$form->addSelectAjax(

@ -67,7 +67,7 @@ if ($session) {
if (!array_key_exists($user->getId(), $usersInfo)) {
$usersInfo[$user->getId()] = [
'code' => $user->getOfficialCode(),
'complete_name' => $user->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($user),
'time_in_platform' => api_time_to_hms(
Tracking::get_time_spent_on_the_platform($user->getId(), 'ever')
),

@ -46,7 +46,7 @@ $userId = $user['user_id'];
$currentUrl = api_get_self().'?user_id='.$userId;
$tool_name = $userEntity->getCompleteName();
$tool_name = UserManager::formatUserFullName($userEntity);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$csvContent = [];

@ -147,7 +147,7 @@ $form = new FormValidator('user_linking_requests', 'get');
$form->addSelectAjax(
'hrm',
get_lang('DRH'),
$hrm ? [$hrm->getId() => $hrm->getCompleteName()] : [],
$hrm ? [$hrm->getId() => UserManager::formatUserFullName($hrm)] : [],
['url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=user_by_role']
);
$form->addButtonFilter(get_lang('Filter'));

@ -924,7 +924,7 @@ class CoursesController
}
$coachId = $session->getGeneralCoach()->getId();
$coachName = $session->getGeneralCoach()->getCompleteName();
$coachName = UserManager::formatUserFullName($session->getGeneralCoach());
$actions = null;
if (api_is_platform_admin()) {
$actions = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session->getId();

@ -58,7 +58,7 @@ foreach ($assignedUsers as $assignedUserId => $assignedUserInfo) {
$userInfo = [
'username' => $assignedUser->getUsername(),
'complete_name' => $assignedUser->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($assignedUser),
'picture_url' => UserManager::getUserPicture($assignedUserId),
'course_list' => $courseController->returnCoursesAndSessions($assignedUserId)['html'],
];

@ -278,7 +278,7 @@ if ($form->validate()) {
Display::return_message(
sprintf(
get_lang('TheUserXHasAlreadyAchievedTheSkillY'),
$user->getCompleteName(),
UserManager::formatUserFullName($user),
$skill->getName()
),
'warning'
@ -337,7 +337,7 @@ if ($form->validate()) {
$subject = get_lang("StudentHadEnoughSkills");
$message = sprintf(
get_lang("StudentXHadEnoughSkillsToGetSkillXToAssignClickHereX"),
$user->getCompleteName(),
UserManager::formatUserFullName($user),
$parentData['name'],
$link
);
@ -359,7 +359,7 @@ if ($form->validate()) {
sprintf(
get_lang('SkillXAssignedToUserY'),
$skill->getName(),
$user->getCompleteName()
UserManager::formatUserFullName($user)
),
'success'
)
@ -369,7 +369,7 @@ if ($form->validate()) {
exit;
}
$form->setDefaults(['user_name' => $user->getCompleteNameWithUsername()]);
$form->setDefaults(['user_name' => UserManager::formatUserFullName($user, true)]);
$form->freeze(['user_name']);
if (api_is_drh()) {
@ -390,7 +390,7 @@ if (api_is_drh()) {
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$userId,
'name' => $user->getCompleteName(),
'name' => UserManager::formatUserFullName($user),
];
} else {
$interbreadcrumb[] = [
@ -403,7 +403,7 @@ if (api_is_drh()) {
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$userId,
'name' => $user->getCompleteName(),
'name' => UserManager::formatUserFullName($user),
];
}

@ -101,7 +101,7 @@ $skillIssueInfo = [
'argumentation' => $skillIssue->getArgumentation(),
'source_name' => $skillIssue->getSourceName(),
'user_id' => $skillIssue->getUser()->getId(),
'user_complete_name' => $skillIssue->getUser()->getCompleteName(),
'user_complete_name' => UserManager::formatUserFullName($skillIssue->getUser()),
'skill_id' => $skillIssue->getSkill()->getId(),
'skill_badge_image' => Skill::getWebIconPath($skillIssue->getSkill()),
'skill_name' => $skillIssue->getSkill()->getName(),
@ -124,7 +124,7 @@ foreach ($skillIssueComments as $comment) {
$skillIssueInfo['comments'][] = [
'text' => $comment->getFeedbackText(),
'value' => $comment->getFeedbackValue(),
'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(),
'giver_complete_name' => UserManager::formatUserFullName($comment->getFeedbackGiver()),
'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT),
];
}

@ -49,7 +49,7 @@ $userSkills = $skillUserRepo->findBy([
$userInfo = [
'id' => $user->getId(),
'complete_name' => $user->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($user),
];
$skillInfo = [
@ -87,7 +87,7 @@ foreach ($userSkills as $index => $skillIssue) {
'argumentation' => $skillIssue->getArgumentation(),
'source_name' => $skillIssue->getSourceName(),
'user_id' => $skillIssue->getUser()->getId(),
'user_complete_name' => $skillIssue->getUser()->getCompleteName(),
'user_complete_name' => UserManager::formatUserFullName($skillIssue->getUser()),
'skill_id' => $skillIssue->getSkill()->getId(),
'skill_badge_image' => Skill::getWebIconPath($skillIssue->getSkill()),
'skill_name' => $skillIssue->getSkill()->getName(),
@ -109,7 +109,7 @@ foreach ($userSkills as $index => $skillIssue) {
$skillIssueInfo['comments'][] = [
'text' => $comment->getFeedbackText(),
'value' => $comment->getFeedbackValue(),
'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(),
'giver_complete_name' => UserManager::formatUserFullName($comment->getFeedbackGiver()),
'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT),
];
}

@ -59,7 +59,7 @@ $teachersData = [];
foreach ($courseTeachers as $teacherSubscription) {
$teacher = $teacherSubscription->getUser();
$userData = [
'complete_name' => $teacher->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($teacher),
'image' => UserManager::getUserPicture(
$teacher->getId(),
USER_IMAGE_SIZE_ORIGINAL

@ -67,7 +67,7 @@ foreach ($sessions as $session) {
);
$bodyTemplate = new Template(null, false, false, false, false, false);
$bodyTemplate->assign('complete_user_name', $user->getCompleteName());
$bodyTemplate->assign('complete_user_name', UserManager::formatUserFullName($user));
$bodyTemplate->assign('session_name', $session->getName());
$bodyLayout = $bodyTemplate->get_template(
@ -75,7 +75,7 @@ foreach ($sessions as $session) {
);
api_mail_html(
$user->getCompleteName(),
UserManager::formatUserFullName($user),
$user->getEmail(),
$subjectTemplate->fetch($subjectLayout),
$bodyTemplate->fetch($bodyLayout),
@ -84,7 +84,7 @@ foreach ($sessions as $session) {
);
echo '============'.PHP_EOL;
echo "Email sent to: {$user->getCompleteName()} ({$user->getEmail()})".PHP_EOL;
echo "Email sent to: ".UserManager::formatUserFullName($user)." ({$user->getEmail()})".PHP_EOL;
echo "Session: {$session->getName()}".PHP_EOL;
echo "End date: {$session->getAccessEndDate()->format('Y-m-d h:i')}".PHP_EOL;
}

@ -2142,7 +2142,7 @@ function getPosts(
$postInfo['username_canonical'] = $user->getUsernameCanonical();
$postInfo['lastname'] = $user->getLastname();
$postInfo['firstname'] = $user->getFirstname();
$postInfo['complete_name'] = $user->getCompleteName();
$postInfo['complete_name'] = UserManager::formatUserFullName($user);
}
}

@ -107,7 +107,7 @@ switch ($action) {
/** @var User $user */
foreach ($users as $user) {
$userName = $user->getCompleteNameWithUsername();
$userName = UserManager::formatUserFullName($user, true);
if ($showEmail) {
$userName .= " ({$user->getEmail()})";

@ -192,7 +192,7 @@ switch ($action) {
foreach ($users as $user) {
$list['items'][] = [
'id' => $user->getId(),
'text' => $user->getCompleteName(),
'text' => UserManager::formatUserFullName($user),
];
}

@ -270,7 +270,7 @@ switch ($action) {
foreach ($users as $user) {
$items[] = [
'id' => $user->getId(),
'text' => $user->getCompleteNameWithUsername(),
'text' => UserManager::formatUserFullName($user, true),
];
}
@ -320,7 +320,7 @@ switch ($action) {
foreach ($users as $user) {
$items[] = [
'id' => $user->getId(),
'text' => $user->getCompleteNameWithUsername(),
'text' => UserManager::formatUserFullName($user, true),
];
}

@ -175,7 +175,7 @@ class CourseChatUtils
$fileContent = '
<div class="message-teacher">
<div class="content-message">
<div class="chat-message-block-name">'.$user->getCompleteName().'</div>
<div class="chat-message-block-name">'.UserManager::formatUserFullName($user).'</div>
<div class="chat-message-block-content">'.$message.'</div>
<div class="message-date">'.$timeNow.'</div>
</div>
@ -189,7 +189,7 @@ class CourseChatUtils
<img class="chat-image" src="'.$userPhoto.'">
<div class="icon-message"></div>
<div class="content-message">
<div class="chat-message-block-name">'.$user->getCompleteName().'</div>
<div class="chat-message-block-name">'.UserManager::formatUserFullName($user).'</div>
<div class="chat-message-block-content">'.$message.'</div>
<div class="message-date">'.$timeNow.'</div>
</div>
@ -757,7 +757,7 @@ class CourseChatUtils
'status' => $status,
'image_url' => UserManager::getUserPicture($user->getId(), USER_IMAGE_SIZE_MEDIUM),
'profile_url' => api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user->getId(),
'complete_name' => $user->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($user),
'username' => $user->getUsername(),
'email' => $user->getEmail(),
'isConnected' => $this->userIsConnected($user->getId()),

@ -73,10 +73,10 @@ class UserAvatar extends HTML_QuickForm_input
$html .= '
<div class="media">
<div class="media-left">
<img src="'.$userPicture.'" alt="'.$this->user->getCompleteName().'">
<img src="'.$userPicture.'" alt="'.UserManager::formatUserFullName($this->user).'">
</div>
<div class="media-body">
<h4 class="media-heading">'.$this->user->getCompleteName().'</h4>
<h4 class="media-heading">'.UserManager::formatUserFullName($this->user).'</h4>
'.$this->subTitle.'
</div>
</div>

@ -230,7 +230,7 @@ class Login
);
api_mail_html(
$user->getCompleteName(),
UserManager::formatUserFullName($user),
$user->getEmail(),
$mailSubject,
$mailBody

@ -2765,7 +2765,7 @@ class MySpace
if (!empty($studentId)) {
$student = api_get_user_entity($studentId);
if ($student) {
$studentList[$student->getId()] = $student->getCompleteName();
$studentList[$student->getId()] = UserManager::formatUserFullName($student);
}
}

@ -132,7 +132,7 @@ class quiz_processor extends search_processor
]);
if ($item_result) {
$author = $item_result->getInsertUser()->getCompleteName();
$author = UserManager::formatUserFullName($item_result->getInsertUser());
}
}

@ -1965,7 +1965,7 @@ class SessionManager
$tplContent->assign('session_name', $session->getName());
$tplContent->assign(
'session_coach',
$session->getGeneralCoach()->getCompleteName()
UserManager::formatUserFullName($session->getGeneralCoach())
);
$layoutContent = $tplContent->get_template(
'mail/content_subscription_to_session_confirmation.tpl'

@ -1309,7 +1309,7 @@ class Template
/** @var User $tutor */
foreach ($tutors as $tutor) {
$names[] = $tutor->getCompleteName();
$names[] = UserManager::formatUserFullName($tutor);
}
return implode(CourseManager::USER_SEPARATOR, $names);
@ -1339,7 +1339,7 @@ class Template
/** @var User $teacher */
foreach ($teachers as $teacher) {
$names[] = $teacher->getCompleteName();
$names[] = UserManager::formatUserFullName($teacher);
}
return implode(CourseManager::USER_SEPARATOR, $names);

@ -6005,7 +6005,7 @@ SQL;
.Display::url($url, $url);
api_mail_html(
$user->getCompleteName(),
UserManager::formatUserFullName($user),
$user->getEmail(),
$mailSubject,
$mailBody
@ -6390,4 +6390,25 @@ SQL;
return $url;
}
/**
* Return the user's full name. Optionally with the username.
*
* @param User $user
* @param bool $includeUsername Optional. By default username is not included.
*
* @return string
*/
public static function formatUserFullName(User $user, $includeUsername = false)
{
$fullName = api_get_person_name($user->getFirstname(), $user->getLastname());
if ($includeUsername && api_get_setting('profile.hide_username_with_complete_name') === 'false') {
$username = $user->getUsername();
return "$fullName ($username)";
}
return $fullName;
}
}

@ -422,7 +422,7 @@ class Rest extends WebService
return [
'id' => intval($announcement['announcement']->getIid()),
'title' => $announcement['announcement']->getTitle(),
'creatorName' => $announcement['item_property']->getInsertUser()->getCompleteName(),
'creatorName' => UserManager::formatUserFullName($announcement['item_property']->getInsertUser()),
'date' => api_convert_and_format_date(
$announcement['item_property']->getInsertDate(),
DATE_TIME_FORMAT_LONG_24H
@ -682,7 +682,7 @@ class Rest extends WebService
$result = [
'pictureUri' => $pictureInfo['dir'].$pictureInfo['file'],
'fullName' => $this->user->getCompleteName(),
'fullName' => UserManager::formatUserFullName($this->user),
'username' => $this->user->getUsername(),
'officialCode' => $this->user->getOfficialCode(),
'phone' => $this->user->getPhone(),
@ -964,7 +964,7 @@ class Rest extends WebService
/** @var User $user */
foreach ($users as $user) {
$userName = $user->getCompleteName();
$userName = UserManager::formatUserFullName($user);
if ($showEmail) {
$userName .= " ({$user->getEmail()})";

@ -62,7 +62,7 @@ if ($session) {
if (!array_key_exists($user->getId(), $usersInfo)) {
$usersInfo[$user->getId()] = [
'code' => $user->getOfficialCode(),
'complete_name' => $user->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($user),
'time_in_platform' => api_time_to_hms(
Tracking::get_time_spent_on_the_platform($user->getId(), 'ever')
),

@ -64,7 +64,7 @@ foreach ($sessionCourses as $sessionRelCourse) {
/** @var User $courseCoach */
foreach ($courseCoaches as $courseCoach) {
$coachData = [
'complete_name' => $courseCoach->getCompleteName(),
'complete_name' => UserManager::formatUserFullName($courseCoach),
'image' => UserManager::getUserPicture(
$courseCoach->getId(),
USER_IMAGE_SIZE_ORIGINAL

@ -172,7 +172,7 @@ if ($session->getNbrCourses() === 0) {
$namesOfCoaches = [];
$coachSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Session::COACH)
->forAll(function ($index, SessionRelCourseRelUser $subscription) use (&$namesOfCoaches) {
$namesOfCoaches[] = $subscription->getUser()->getCompleteNameWithUserName();
$namesOfCoaches[] = UserManager::formatUserFullName($subscription->getUser(), true);
return true;
});

@ -103,7 +103,7 @@ $interbreadcrumb[] = [
];
Display::display_header($tool_name);
echo Display::page_header($session->getName().' - '.$user->getCompleteName());
echo Display::page_header($session->getName().' - '.UserManager::formatUserFullName($user));
?>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">

@ -4,7 +4,7 @@
<div class="panel-body">
<div class="profile-user">
{{ user_avatar }}
<div class="username">{{ user.getCompleteName() }}</div>
<div class="username">{{ user|format_user_full_name }}</div>
<div class="star-progress">
<span class="pull-right">{{ 'XPoints'|get_lang|format(gamification_points) }}</span>

@ -11,7 +11,7 @@
</p>
{% if show_tutor %}
<p>
<em class="fa fa-user"></em> {{ 'SessionGeneralCoach'|get_lang }}: <em>{{ session.generalCoach.getCompleteName() }}</em>
<em class="fa fa-user"></em> {{ 'SessionGeneralCoach'|get_lang }}: <em>{{ session.generalCoach|format_user_full_name }}</em>
</p>
{% endif %}

@ -50,7 +50,7 @@ foreach ($meetings as &$meeting) {
foreach ($participants as $meetingParticipant) {
/** @var User $participant */
$participant = $meetingParticipant['participant'];
$meeting['participants'][] = $participant->getCompleteName().' ('.$participant->getEmail().')';
$meeting['participants'][] = UserManager::formatUserFullName($participant).' ('.$participant->getEmail().')';
}
}

@ -461,7 +461,7 @@ class BuyCoursesPlugin extends Plugin
}
$sessionData = $this->getSessionInfo($session->getId());
$sessionData['coach'] = $session->getGeneralCoach()->getCompleteName();
$sessionData['coach'] = UserManager::formatUserFullName($session->getGeneralCoach());
$sessionData['enrolled'] = $this->getUserStatusForSession(
api_get_user_id(),
$session
@ -483,7 +483,7 @@ class BuyCoursesPlugin extends Plugin
foreach ($userCourseSubscriptions as $userCourseSubscription) {
$user = $userCourseSubscription->getUser();
$sessionCourseData['coaches'][] = $user->getCompleteName();
$sessionCourseData['coaches'][] = UserManager::formatUserFullName($user);
}
$sessionData['courses'][] = $sessionCourseData;
@ -536,7 +536,7 @@ class BuyCoursesPlugin extends Plugin
foreach ($course->getTeachers() as $courseUser) {
$teacher = $courseUser->getUser();
$courseItem['teachers'][] = $teacher->getCompleteName();
$courseItem['teachers'][] = UserManager::formatUserFullName($teacher);
}
//check images
@ -607,7 +607,7 @@ class BuyCoursesPlugin extends Plugin
foreach ($courseTeachers as $teachers) {
$user = $teachers->getUser();
$teacher['id'] = $user->getId();
$teacher['name'] = $user->getCompleteName();
$teacher['name'] = UserManager::formatUserFullName($user);
$courseInfo['teachers'][] = $teacher;
}
@ -697,7 +697,7 @@ class BuyCoursesPlugin extends Plugin
foreach ($userCourseSubscriptions as $userCourseSubscription) {
$user = $userCourseSubscription->getUser();
$coaches['id'] = $user->getUserId();
$coaches['name'] = $user->getCompleteName();
$coaches['name'] = UserManager::formatUserFullName($user);
$sessionCourseData['coaches'][] = $coaches;
}

@ -478,7 +478,7 @@ switch ($action) {
$nodeType = get_lang('User');
/** @var User $user */
$user = UserManager::getManager()->find($serviceSale['node_id']);
$nodeName = $user ? $user->getCompleteNameWithUsername() : null;
$nodeName = $user ? UserManager::formatUserFullName($user, true) : null;
} else {
if ($nodeType == BuyCoursesPlugin::SERVICE_TYPE_COURSE) {
$nodeType = get_lang('Course');

@ -57,7 +57,7 @@ if ($editingCourse) {
foreach ($teachers as $courseTeacher) {
$teacher = $courseTeacher->getUser();
$teachersOptions[] = [
'text' => $teacher->getCompleteName(),
'text' => UserManager::formatUserFullName($teacher),
'value' => $teacher->getId(),
];
@ -105,7 +105,7 @@ if ($editingCourse) {
$sessionItem = $plugin->getSessionForConfiguration($session, $currency);
$generalCoach = $session->getGeneralCoach();
$generalCoachOption = [
'text' => $generalCoach->getCompleteName(),
'text' => UserManager::formatUserFullName($generalCoach),
'value' => $generalCoach->getId(),
];
$defaultBeneficiaries = [
@ -123,7 +123,7 @@ if ($editingCourse) {
}
$courseCoachesOptions[] = [
'text' => $courseCoach->getCompleteName(),
'text' => UserManager::formatUserFullName($courseCoach),
'value' => $courseCoach->getId(),
];
$defaultBeneficiaries[] = $courseCoach->getId();

@ -126,7 +126,7 @@ if ($typeUser) {
/** @var User $user */
foreach ($users as $user) {
if (intval($userInfo['user_id']) !== intval($user->getId())) {
$selectOptions[$user->getId()] = $user->getCompleteNameWithUsername();
$selectOptions[$user->getId()] = UserManager::formatUserFullName($user, true);
}
}
}

@ -17,7 +17,7 @@ $users = UserManager::getRepository()->findAll();
$userOptions = [];
if (!empty($users)) {
foreach ($users as $user) {
$userOptions[$user->getId()] = $user->getCompleteNameWithUsername();
$userOptions[$user->getId()] = UserManager::formatUserFullName($user, true);
}
}

@ -23,7 +23,7 @@ $users = UserManager::getRepository()->findAll();
$userOptions = [];
if (!empty($users)) {
foreach ($users as $user) {
$userOptions[$user->getId()] = $user->getCompleteNameWithUsername();
$userOptions[$user->getId()] = UserManager::formatUserFullName($user, true);
}
}

@ -45,7 +45,7 @@ $params = [
'lis_person_name_given' => $user->getFirstname(),
'lis_person_name_family' => $user->getLastname(),
'lis_person_name_full' => $user->getCompleteName(),
'lis_person_name_full' => UserManager::formatUserFullName($user),
'lis_person_contact_email_primary' => $user->getEmail(),
'context_id' => $course->getId(),

@ -27,6 +27,7 @@ class ChamiloExtension extends \Twig_Extension
new \Twig_SimpleFilter('format_date', 'Template::format_date'),
new \Twig_SimpleFilter('date_to_time_ago', 'Display::dateToStringAgoAndLongDate'),
new \Twig_SimpleFilter('api_get_configuration_value', 'api_get_configuration_value'),
new \Twig_SimpleFilter('format_user_full_name', 'UserManager::formatUserFullName'),
];
}

@ -496,7 +496,7 @@ class User extends BaseUser implements ThemeUser, EquatableInterface //implement
*/
public function __toString()
{
return $this->getCompleteName();
return \UserManager::formatUserFullName();
}
/**
@ -780,30 +780,6 @@ class User extends BaseUser implements ThemeUser, EquatableInterface //implement
});*/
}
/**
* Return Complete Name with the Username.
*
* @return string
*/
public function getCompleteNameWithUsername()
{
if (api_get_setting('profile.hide_username_with_complete_name') === 'true') {
return $this->getCompleteName();
}
return api_get_person_name($this->firstname, $this->lastname).' ('.$this->username.')';
}
/**
* @todo don't use api_get_person_name
*
* @return string
*/
public function getCompleteName()
{
return api_get_person_name($this->firstname, $this->lastname);
}
/**
* Returns the list of classes for the user.
*
@ -820,7 +796,7 @@ class User extends BaseUser implements ThemeUser, EquatableInterface //implement
}
$classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null;
return $this->getCompleteName().$classString;
return \UserManager::formatUserFullName($this).$classString;
}
/**

Loading…
Cancel
Save