MDL-64119 user: Display full names consistently for teachers
authorSara Arjona <sara@moodle.com>
Tue, 20 Nov 2018 14:05:36 +0000 (15:05 +0100)
committerSara Arjona <sara@moodle.com>
Tue, 20 Nov 2018 18:41:21 +0000 (19:41 +0100)
Fix an error with users with the moodle/site:viewfullnames capability
in a course context (like teachers), to display properly the full
names in pages like the participants one.

lib/outputrenderers.php
lib/tablelib.php

index 5e60efd..21787cd 100644 (file)
@@ -2575,10 +2575,10 @@ class core_renderer extends renderer_base {
      * @return string
      */
     protected function render_user_picture(user_picture $userpicture) {
-        global $CFG, $DB;
+        global $CFG, $DB, $PAGE;
 
         $user = $userpicture->user;
-        $canviewfullnames = has_capability('moodle/site:viewfullnames', context_system::instance());
+        $canviewfullnames = has_capability('moodle/site:viewfullnames', $PAGE->context);
 
         if ($userpicture->alttext) {
             if (!empty($user->imagealt)) {
index a35a49a..4405bc6 100644 (file)
@@ -1200,7 +1200,7 @@ class flexible_table {
      * This function is not part of the public api.
      */
     function print_headers() {
-        global $CFG, $OUTPUT;
+        global $CFG, $OUTPUT, $PAGE;
 
         echo html_writer::start_tag('thead');
         echo html_writer::start_tag('tr');
@@ -1222,7 +1222,7 @@ class flexible_table {
 
                 case 'fullname':
                     // Check the full name display for sortable fields.
-                    if (has_capability('moodle/site:viewfullnames', context_system::instance())) {
+                    if (has_capability('moodle/site:viewfullnames', $PAGE->context)) {
                         $nameformat = $CFG->alternativefullnameformat;
                     } else {
                         $nameformat = $CFG->fullnamedisplay;