diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 47d87283a06..1223ef64a8d 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2496,12 +2496,13 @@ class core_renderer extends renderer_base { global $CFG, $DB; $user = $userpicture->user; + $canviewfullnames = has_capability('moodle/site:viewfullnames', context_system::instance()); if ($userpicture->alttext) { if (!empty($user->imagealt)) { $alt = $user->imagealt; } else { - $alt = get_string('pictureof', '', fullname($user)); + $alt = get_string('pictureof', '', fullname($user, $canviewfullnames)); } } else { $alt = ''; @@ -2533,7 +2534,7 @@ class core_renderer extends renderer_base { // Show fullname together with the picture when desired. if ($userpicture->includefullname) { - $output .= fullname($userpicture->user); + $output .= fullname($userpicture->user, $canviewfullnames); } // then wrap it in link if needed diff --git a/lib/tablelib.php b/lib/tablelib.php index 8235cbf1c81..a35a49a290e 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -1221,29 +1221,35 @@ class flexible_table { switch ($column) { case 'fullname': - // Check the full name display for sortable fields. - $nameformat = $CFG->fullnamedisplay; - if ($nameformat == 'language') { - $nameformat = get_string('fullnamedisplay'); - } - $requirednames = order_in_string(get_all_user_name_fields(), $nameformat); - - if (!empty($requirednames)) { - if ($this->is_sortable($column)) { - // Done this way for the possibility of more than two sortable full name display fields. - $this->headers[$index] = ''; - foreach ($requirednames as $name) { - $sortname = $this->sort_link(get_string($name), - $name, $primarysortcolumn === $name, $primarysortorder); - $this->headers[$index] .= $sortname . ' / '; - } - $helpicon = ''; - if (isset($this->helpforheaders[$index])) { - $helpicon = $OUTPUT->render($this->helpforheaders[$index]); - } - $this->headers[$index] = substr($this->headers[$index], 0, -3). $helpicon; + // Check the full name display for sortable fields. + if (has_capability('moodle/site:viewfullnames', context_system::instance())) { + $nameformat = $CFG->alternativefullnameformat; + } else { + $nameformat = $CFG->fullnamedisplay; + } + + if ($nameformat == 'language') { + $nameformat = get_string('fullnamedisplay'); + } + + $requirednames = order_in_string(get_all_user_name_fields(), $nameformat); + + if (!empty($requirednames)) { + if ($this->is_sortable($column)) { + // Done this way for the possibility of more than two sortable full name display fields. + $this->headers[$index] = ''; + foreach ($requirednames as $name) { + $sortname = $this->sort_link(get_string($name), + $name, $primarysortcolumn === $name, $primarysortorder); + $this->headers[$index] .= $sortname . ' / '; + } + $helpicon = ''; + if (isset($this->helpforheaders[$index])) { + $helpicon = $OUTPUT->render($this->helpforheaders[$index]); + } + $this->headers[$index] = substr($this->headers[$index], 0, -3). $helpicon; + } } - } break; case 'userpic': @@ -1251,14 +1257,14 @@ class flexible_table { break; default: - if ($this->is_sortable($column)) { - $helpicon = ''; - if (isset($this->helpforheaders[$index])) { - $helpicon = $OUTPUT->render($this->helpforheaders[$index]); + if ($this->is_sortable($column)) { + $helpicon = ''; + if (isset($this->helpforheaders[$index])) { + $helpicon = $OUTPUT->render($this->helpforheaders[$index]); + } + $this->headers[$index] = $this->sort_link($this->headers[$index], + $column, $primarysortcolumn == $column, $primarysortorder) . $helpicon; } - $this->headers[$index] = $this->sort_link($this->headers[$index], - $column, $primarysortcolumn == $column, $primarysortorder) . $helpicon; - } } $attributes = array( diff --git a/mod/forum/lib.php b/mod/forum/lib.php index c0bf984e078..fa122eabc75 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -3819,6 +3819,7 @@ function forum_print_discussion_header(&$post, $forum, $group = -1, $datestring $post->subject = format_string($post->subject,true); + $canviewfullnames = has_capability('moodle/site:viewfullnames', $modcontext); $timeddiscussion = !empty($CFG->forum_enabletimedposts) && ($post->timestart || $post->timeend); $timedoutsidewindow = ''; if ($timeddiscussion && ($post->timestart > time() || ($post->timeend != 0 && $post->timeend < time()))) { @@ -3856,7 +3857,7 @@ function forum_print_discussion_header(&$post, $forum, $group = -1, $datestring echo ''; // User name echo '