global $CFG, $USER;
- require_once("$CFG->dirroot/enrol/enrol.class.php");
-
- $enrol = enrolment_factory::factory($course->enrol);
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
- print_simple_box_start("center", "$width", '', 5, "coursebox");
+ print_simple_box_start('center', $width, '', 5, 'coursebox');
- $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
+ $linkcss = $course->visible ? '' : ' class="dimmed" ';
- echo "<table width=\"100%\">";
+ echo '<table width="100%">';
echo '<tr valign="top">';
echo '<td valign="top" width="50%" class="info">';
echo '<b><a title="'.get_string('entercourse').'"'.
$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
$course->fullname.'</a></b><br />';
- if ($teachers = get_course_teachers($course->id)) {
- echo "<span class=\"teachers\">\n";
+
+ if ($teachers = get_users_by_capability($context, 'moodle/course:update')) {
+ $canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
+ $namesarray = array();
foreach ($teachers as $teacher) {
- if (empty($teacher->role)) {
- $teacher->role = $course->teacher;
+ if (!$teacher->hidden || $canseehidden) {
+ $roles = get_user_roles($context, $teacher->id);
+ $role = array_shift($roles); // First one
+ $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
+ $namesarray[] = format_string($role->name).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
+ $teacher->id.'&course='.SITEID.'">'.$fullname.'</a>';
}
- $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); // is the USER a teacher of that course
- echo $teacher->role.': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.
- '&course='.SITEID.'">'.$fullname.'</a><br />';
}
- echo "</span>\n";
+ if ($namesarray) {
+ echo "<ul class=\"teachers\">\n<li>";
+ echo implode('</li><li>', $namesarray);
+ echo "</li></ul>";
+ }
}
+ require_once("$CFG->dirroot/enrol/enrol.class.php");
+ $enrol = enrolment_factory::factory($course->enrol);
echo $enrol->get_access_icons($course);
echo '</td><td valign="top" width="50%" class="summary">';