Skip to content

Commit

Permalink
MDL-55915 enrol_manual: let fullname()know if user has viewfullnames cap
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Shamim Rezaie committed Jan 20, 2017
1 parent ee8f39b commit d636015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion enrol/manual/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@
} 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});
Expand Down
3 changes: 3 additions & 0 deletions enrol/manual/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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.
Expand Down Expand Up @@ -74,7 +75,9 @@
$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');
Expand Down

0 comments on commit d636015

Please sign in to comment.