From b14507a31f2b901258a5a2e84ea1be8861ec5cff Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Fri, 20 Jan 2017 19:31:08 +1100 Subject: [PATCH] MDL-55915 enrol_manual: let fullname()know if user has viewfullnames cap fullname() relies on its second parameter to determine wheter it should use fullnamedisplay or alternativefullnameformat. We need to check for moodle/site:viewfullnames capability and pass true as the second parameter to fullname() whereever the user has this capability. --- enrol/manual/ajax.php | 3 ++- enrol/manual/manage.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/enrol/manual/ajax.php b/enrol/manual/ajax.php index ad454c47a4c..8cb081a2bd4 100644 --- a/enrol/manual/ajax.php +++ b/enrol/manual/ajax.php @@ -80,9 +80,10 @@ switch ($action) { } else { $useroptions['link'] = false; } + $viewfullnames = has_capability('moodle/site:viewfullnames', $context); foreach ($outcome->response['users'] as &$user) { $user->picture = $OUTPUT->user_picture($user, $useroptions); - $user->fullname = fullname($user); + $user->fullname = fullname($user, $viewfullnames); $fieldvalues = array(); foreach ($extrafields as $field) { $fieldvalues[] = s($user->{$field}); diff --git a/enrol/manual/manage.php b/enrol/manual/manage.php index 17627f8d605..e3161d4b045 100644 --- a/enrol/manual/manage.php +++ b/enrol/manual/manage.php @@ -37,6 +37,7 @@ $context = context_course::instance($course->id, MUST_EXIST); require_login($course); $canenrol = has_capability('enrol/manual:enrol', $context); $canunenrol = has_capability('enrol/manual:unenrol', $context); +$viewfullnames = has_capability('moodle/site:viewfullnames', $context); // Note: manage capability not used here because it is used for editing // of existing enrolments which is not possible here. @@ -74,7 +75,9 @@ navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('i $options = array('enrolid' => $enrolid, 'accesscontext' => $context); $potentialuserselector = new enrol_manual_potential_participant('addselect', $options); +$potentialuserselector->viewfullnames = $viewfullnames; $currentuserselector = new enrol_manual_current_participant('removeselect', $options); +$currentuserselector->viewfullnames = $viewfullnames; // Build the list of options for the enrolment period dropdown. $unlimitedperiod = get_string('unlimited');