MDL-67245 group: observe viewfullnames capability.

This commit is contained in:
Paul Holden 2020-01-07 16:18:56 +00:00
parent 21253ed622
commit 6e8ed1a8fb
5 changed files with 16 additions and 8 deletions

View File

@ -172,7 +172,7 @@ if ($editform->is_cancelled()) {
$table->width = '90%';
}
$table->data = array();
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($groups as $group) {
$line = array();
if (groups_get_group_by_name($courseid, $group['name'])) {
@ -184,7 +184,7 @@ if ($editform->is_cancelled()) {
if ($data->allocateby != 'no') {
$unames = array();
foreach ($group['members'] as $user) {
$fullname = fullname($user, true);
$fullname = fullname($user, $viewfullnames);
if ($extrafields) {
$extrafieldsdisplay = [];
foreach ($extrafields as $field) {

View File

@ -77,8 +77,10 @@ class user_groups_editable extends \core\output\inplace_editable {
foreach ($coursegroups as $group) {
$options[$group->id] = format_string($group->name, true, ['context' => $this->context]);
}
$this->edithint = get_string('editusersgroupsa', 'group', fullname($user));
$this->editlabel = get_string('editusersgroupsa', 'group', fullname($user));
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $this->context));
$this->edithint = get_string('editusersgroupsa', 'group', $fullname);
$this->editlabel = get_string('editusersgroupsa', 'group', $fullname);
$attributes = ['multiple' => true];
$this->set_type_autocomplete($options, $attributes);

View File

@ -556,7 +556,8 @@ class core_group_external extends external_api {
require_capability('moodle/course:managegroups', $context);
if (!groups_remove_member_allowed($group, $user)) {
throw new moodle_exception('errorremovenotpermitted', 'group', '', fullname($user));
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
throw new moodle_exception('errorremovenotpermitted', 'group', '', $fullname);
}
groups_remove_member($group, $user);
}

View File

@ -85,6 +85,8 @@ switch ($action) {
if ($groupmemberroles = groups_get_members_by_role($groupids[0], $courseid,
'u.id, ' . user_picture::fields('u', $extrafields))) {
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach($groupmemberroles as $roleid=>$roledata) {
$shortroledata = new stdClass();
$shortroledata->name = $roledata->name;
@ -92,7 +94,7 @@ switch ($action) {
foreach($roledata->users as $member) {
$shortmember = new stdClass();
$shortmember->id = $member->id;
$shortmember->name = fullname($member, true);
$shortmember->name = fullname($member, $viewfullnames);
if ($extrafields) {
$extrafieldsdisplay = [];
foreach ($extrafields as $field) {
@ -204,12 +206,14 @@ if ($singlegroup) {
if ($groupmemberroles = groups_get_members_by_role(reset($groupids), $courseid,
'u.id, ' . user_picture::fields('u', $extrafields))) {
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($groupmemberroles as $roleid => $roledata) {
$users = array();
foreach ($roledata->users as $member) {
$shortmember = new stdClass();
$shortmember->value = $member->id;
$shortmember->text = fullname($member, true);
$shortmember->text = fullname($member, $viewfullnames);
if ($extrafields) {
$extrafieldsdisplay = [];
foreach ($extrafields as $field) {

View File

@ -251,9 +251,10 @@ foreach ($members as $gpgid=>$groupdata) {
$line[] = html_writer::tag('span', $name, array('class' => 'group_hoverdescription', 'data-groupid' => $gpid));
$hoverevents[$gpid] = get_string('descriptiona', null, $jsdescription);
}
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
$fullnames = array();
foreach ($users as $user) {
$displayname = fullname($user, true);
$displayname = fullname($user, $viewfullnames);
if ($extrafields) {
$extrafieldsdisplay = [];
foreach ($extrafields as $field) {