-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add assigned users course list for HRM - refs BT#12955
- Loading branch information
Showing
4 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/* For licensing terms, see /license.txt */ | ||
|
||
use Chamilo\CoreBundle\Entity\CourseRelUser, | ||
Chamilo\CoreBundle\Entity\SessionRelCourseRelUser, | ||
Chamilo\CoreBundle\Entity\Course; | ||
|
||
require_once __DIR__.'/../inc/global.inc.php'; | ||
|
||
api_block_anonymous_users(true); | ||
|
||
$isHrm = api_is_drh(); | ||
|
||
if (!$isHrm) { | ||
api_not_allowed(true); | ||
} | ||
|
||
function formatCourseInfo(Course $course, $sessionId = 0, $showCourseCode = false) | ||
{ | ||
$sysCoursePath = api_get_path(SYS_COURSE_PATH).$course->getDirectory(); | ||
$webCoursePath = api_get_path(WEB_COURSE_PATH).$course->getDirectory(); | ||
|
||
return [ | ||
'visibility' => $course->getVisibility(), | ||
'link' => api_get_course_url($course->getCode(), $sessionId), | ||
'category' => $course->getCategoryCode(), | ||
'title' => $course->getTitle(), | ||
'title_cut' => $course->getTitle(), | ||
'code_course' => $showCourseCode ? $course->getCode() : null, | ||
'image' => file_exists($sysCoursePath.'/course-pic.png') | ||
? $webCoursePath.'/course-pic.png' | ||
: Display::returnIconPath('session_default.png'), | ||
'teachers' => api_get_setting('display_teacher_in_courselist') === 'true' | ||
? $teachers = CourseManager::getTeachersFromCourse($course->getId(), true) | ||
: [] | ||
]; | ||
} | ||
|
||
$showCourseCode = api_get_configuration_value('display_coursecode_in_courselist') === 'true'; | ||
|
||
$hrm = api_get_user_entity(api_get_user_id()); | ||
$assignedUsers = UserManager::get_users_followed_by_drh($hrm->getId()); | ||
$users = []; | ||
|
||
$courseController = new IndexManager(''); | ||
|
||
foreach ($assignedUsers as $assignedUserId => $assignedUserInfo) { | ||
$assignedUser = api_get_user_entity($assignedUserId); | ||
|
||
if (!$assignedUser) { | ||
continue; | ||
} | ||
|
||
$userInfo = [ | ||
'username' => $assignedUser->getUsername(), | ||
'complete_name' => $assignedUser->getCompleteName(), | ||
'picture_url' => UserManager::getUserPicture($assignedUserId), | ||
'course_list' => $courseController->returnCoursesAndSessions($assignedUserId)['html'] | ||
]; | ||
|
||
$users[$assignedUser->getId()] = $userInfo; | ||
} | ||
|
||
$toolName = get_lang('HrmAssignedUsersCourseList'); | ||
|
||
$view = new Template($toolName); | ||
$view->assign('users', $users); | ||
|
||
$content = $view->fetch( | ||
$view->get_template('auth/hrm_courses.tpl') | ||
); | ||
|
||
$view->assign('header', $toolName); | ||
$view->assign('content', $content); | ||
$view->display_one_col_template(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% for user in users %} | ||
<div class="panel panel-info"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"> | ||
<img src="{{ user.picture_url }}" alt="{{ user.complete_name }}"> | ||
{{ user.complete_name }} | ||
<small>{{ user.username }}</small> | ||
</h3> | ||
</div> | ||
<div class="panel-body"> | ||
{% if not user.course_list %} | ||
<div class="alert alert-warning">{{ 'UserHasNoCourse'|get_lang }}</div> | ||
{% else %} | ||
{{ user.course_list }} | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% endfor %} |