diff --git a/course/info.php b/course/info.php
index 4da6eb3..f36d05d 100644
--- a/course/info.php
+++ b/course/info.php
@@ -56,26 +56,7 @@
     $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
     echo format_text($course->summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
 
-    if (!empty($CFG->coursecontact)) {
-        $coursecontactroles = explode(',', $CFG->coursecontact);
-        foreach ($coursecontactroles as $roleid) {
-            $role = $DB->get_record('role', array('id'=>$roleid));
-            $roleid = (int) $roleid;
-            if ($users = get_role_users($roleid, $context, true)) {
-                foreach ($users as $teacher) {
-                    $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
-                    $namesarray[] = format_string(role_get_name($role, $context)).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
-                                    $teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
-                }
-            }
-        }
-
-        if (!empty($namesarray)) {
-            echo "<ul class=\"teachers\">\n<li>";
-            echo implode('</li><li>', $namesarray);
-            echo "</li></ul>";
-        }
-    }
+    print_course_contact($course);
 
 // TODO: print some enrol icons
 
diff --git a/course/lib.php b/course/lib.php
index 6b4874e..b65f8b4 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -2497,7 +2497,7 @@ function print_courses($category) {
  * @param string $highlightterms (optional) some search terms that should be highlighted in the display.
  */
 function print_course($course, $highlightterms = '') {
-    global $CFG, $USER, $DB, $OUTPUT;
+    global $OUTPUT;
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
 
@@ -2519,6 +2519,40 @@ function print_course($course, $highlightterms = '') {
     echo html_writer::link($linkhref, $linktext, $linkparams);
     echo html_writer::end_tag('h3');
 
+    print_course_contact($course);
+
+    echo html_writer::end_tag('div'); // End of info div
+
+    echo html_writer::start_tag('div', array('class'=>'summary'));
+    $options = new stdClass();
+    $options->noclean = true;
+    $options->para = false;
+    $options->overflowdiv = true;
+    if (!isset($course->summaryformat)) {
+        $course->summaryformat = FORMAT_MOODLE;
+    }
+    echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options,  $course->id));
+    if ($icons = enrol_get_course_info_icons($course)) {
+        echo html_writer::start_tag('div', array('class'=>'enrolmenticons'));
+        foreach ($icons as $icon) {
+            echo $OUTPUT->render($icon);
+        }
+        echo html_writer::end_tag('div'); // End of enrolmenticons div
+    }
+    echo html_writer::end_tag('div'); // End of summary div
+    echo html_writer::end_tag('div'); // End of coursebox div
+}
+
+/**
+ * Print course contact information in a reusable way.
+ *
+ * @param object $course the course object.
+ */
+function print_course_contact($course) {
+    global $CFG, $DB;
+
+    $context = get_context_instance(CONTEXT_COURSE, $course->id);
+
     /// first find all roles that are supposed to be displayed
     if (!empty($CFG->coursecontact)) {
         $managerroles = explode(',', $CFG->coursecontact);
@@ -2548,9 +2582,18 @@ function print_course($course, $highlightterms = '') {
             $aliasnames = $DB->get_records('role_names', array('contextid'=>$context->id), '', 'roleid,contextid,name');
         }
 
-        $namesarray = array();
+        $enrolledusers = array();
+        foreach (get_enrolled_users($context) as $enrolleduser) {
+            $enrolledusers[$enrolleduser->id] = TRUE;
+        }
+
         $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
         foreach ($rusers as $ra) {
+            if (empty($enrolledusers[$ra->id])) {
+                //  only display users who are enrolled in the course
+                continue;
+            }
+
             if (isset($namesarray[$ra->id])) {
                 //  only display a user once with the higest sortorder role
                 continue;
@@ -2573,26 +2616,6 @@ function print_course($course, $highlightterms = '') {
             echo html_writer::end_tag('ul');
         }
     }
-    echo html_writer::end_tag('div'); // End of info div
-
-    echo html_writer::start_tag('div', array('class'=>'summary'));
-    $options = new stdClass();
-    $options->noclean = true;
-    $options->para = false;
-    $options->overflowdiv = true;
-    if (!isset($course->summaryformat)) {
-        $course->summaryformat = FORMAT_MOODLE;
-    }
-    echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options,  $course->id));
-    if ($icons = enrol_get_course_info_icons($course)) {
-        echo html_writer::start_tag('div', array('class'=>'enrolmenticons'));
-        foreach ($icons as $icon) {
-            echo $OUTPUT->render($icon);
-        }
-        echo html_writer::end_tag('div'); // End of enrolmenticons div
-    }
-    echo html_writer::end_tag('div'); // End of summary div
-    echo html_writer::end_tag('div'); // End of coursebox div
 }
 
 /**
diff --git a/enrol/index.php b/enrol/index.php
index 14e7da2..ec17817 100644
--- a/enrol/index.php
+++ b/enrol/index.php
@@ -88,26 +88,7 @@ echo $OUTPUT->box_start('generalbox info');
 
 $summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
 echo format_text($summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
-if (!empty($CFG->coursecontact)) {
-    $coursecontactroles = explode(',', $CFG->coursecontact);
-    foreach ($coursecontactroles as $roleid) {
-        $role = $DB->get_record('role', array('id'=>$roleid));
-        $roleid = (int) $roleid;
-        if ($users = get_role_users($roleid, $context, true)) {
-            foreach ($users as $teacher) {
-                $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
-                $namesarray[] = format_string(role_get_name($role, $context)).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
-                    $teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
-            }
-        }
-    }
-
-    if (!empty($namesarray)) {
-        echo "<ul class=\"teachers\">\n<li>";
-        echo implode('</li><li>', $namesarray);
-        echo "</li></ul>";
-    }
-}
+print_course_contact($course);
 
 echo $OUTPUT->box_end();
 
