MDL-62618 user: Display full names consistently on users page
This commit is contained in:
@@ -2482,12 +2482,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 = '';
|
||||
@@ -2519,7 +2520,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
|
||||
|
||||
+33
-27
@@ -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);
|
||||
// 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 (!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]);
|
||||
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;
|
||||
}
|
||||
$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(
|
||||
|
||||
@@ -366,7 +366,8 @@ class participants_table extends \table_sql {
|
||||
$enrolstatusoutput = '';
|
||||
$canreviewenrol = has_capability('moodle/course:enrolreview', $this->context);
|
||||
if ($canreviewenrol) {
|
||||
$fullname = fullname($data);
|
||||
$canviewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
|
||||
$fullname = fullname($data, $canviewfullnames);
|
||||
$coursename = format_string($this->course->fullname, true, array('context' => $this->context));
|
||||
require_once($CFG->dirroot . '/enrol/locallib.php');
|
||||
$manager = new \course_enrolment_manager($PAGE, $this->course);
|
||||
|
||||
+1
-1
@@ -335,7 +335,7 @@ function user_get_user_details($user, $course = null, array $userfields = array(
|
||||
$userdetails['lastname'] = $user->lastname;
|
||||
}
|
||||
}
|
||||
$userdetails['fullname'] = fullname($user);
|
||||
$userdetails['fullname'] = fullname($user, $canviewfullnames);
|
||||
|
||||
if (in_array('customfields', $userfields)) {
|
||||
$categories = profile_get_user_fields_with_data_by_category($user->id);
|
||||
|
||||
Reference in New Issue
Block a user