Upgrading print_course to use roles properly

Added list for the teacher names for better XHTML
This commit is contained in:
moodler 2006-09-16 15:23:41 +00:00
parent 5b6306677b
commit 88768091a4

View File

@ -1510,33 +1510,40 @@ function print_course($course, $width="100%") {
global $CFG, $USER;
require_once("$CFG->dirroot/enrol/enrol.class.php");
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$enrol = enrolment_factory::factory($course->enrol);
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.'&amp;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.
'&amp;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">';