hrm_courses.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Entity\Course;
  4. require_once __DIR__.'/../inc/global.inc.php';
  5. api_block_anonymous_users(true);
  6. $isHrm = api_is_drh();
  7. if (!$isHrm) {
  8. api_not_allowed(true);
  9. }
  10. function formatCourseInfo(Course $course, $sessionId = 0, $showCourseCode = false)
  11. {
  12. $sysCoursePath = api_get_path(SYS_COURSE_PATH).$course->getDirectory();
  13. $webCoursePath = api_get_path(WEB_COURSE_PATH).$course->getDirectory();
  14. return [
  15. 'visibility' => $course->getVisibility(),
  16. 'link' => api_get_course_url($course->getCode(), $sessionId),
  17. 'category' => $course->getCategoryCode(),
  18. 'title' => $course->getTitle(),
  19. 'title_cut' => $course->getTitle(),
  20. 'code_course' => $showCourseCode ? $course->getCode() : null,
  21. 'image' => file_exists($sysCoursePath.'/course-pic.png')
  22. ? $webCoursePath.'/course-pic.png'
  23. : Display::return_icon(
  24. 'session_default.png',
  25. null,
  26. null,
  27. null,
  28. null,
  29. true
  30. ),
  31. 'teachers' => api_get_setting('display_teacher_in_courselist') === 'true'
  32. ? $teachers = CourseManager::getTeachersFromCourse($course->getId(), true)
  33. : [],
  34. ];
  35. }
  36. $showCourseCode = api_get_configuration_value('display_coursecode_in_courselist') === 'true';
  37. $hrm = api_get_user_entity(api_get_user_id());
  38. $assignedUsers = UserManager::get_users_followed_by_drh($hrm->getId());
  39. $users = [];
  40. $courseController = new IndexManager('');
  41. foreach ($assignedUsers as $assignedUserId => $assignedUserInfo) {
  42. $assignedUser = api_get_user_entity($assignedUserId);
  43. if (!$assignedUser) {
  44. continue;
  45. }
  46. $userInfo = [
  47. 'username' => $assignedUser->getUsername(),
  48. 'complete_name' => UserManager::formatUserFullName($assignedUser),
  49. 'picture_url' => UserManager::getUserPicture($assignedUserId),
  50. 'course_list' => $courseController->returnCoursesAndSessions($assignedUserId)['html'],
  51. ];
  52. $users[$assignedUser->getId()] = $userInfo;
  53. }
  54. $toolName = get_lang('HrmAssignedUsersCourseList');
  55. $view = new Template($toolName);
  56. $view->assign('users', $users);
  57. $content = $view->fetch(
  58. $view->get_template('auth/hrm_courses.tpl')
  59. );
  60. $view->assign('header', $toolName);
  61. $view->assign('content', $content);
  62. $view->display_one_col_template();