Commit 58f6e37b authored by Astor Bizard's avatar Astor Bizard
Browse files

Minor database optimization to retrieve users and groups names.

parent 6b5319ed
......@@ -381,14 +381,12 @@ foreach ($overrides as $override) {
// Set up a proper display for affected users and groups.
$users = array();
if (!empty($override->userids)) {
$users[] = implode(', ', array_map(function($userid) use ($DB) {
return fullname($DB->get_record('user', array('id' => $userid)));
}, explode(',', $override->userids)));
$users = array_map('fullname', $DB->get_records_list('user', 'id', explode(',', $override->userids), 'id'));
}
if (!empty($override->groupids)) {
$users[] = implode(', ', array_map(function($groupid) {
return '<i class="fa fa-fw fa-group"></i>&nbsp;' . groups_get_group_name($groupid);
}, explode(',', $override->groupids)));
$users = array_merge($users, array_map(function($group) {
return '<i class="fa fa-fw fa-group"></i>&nbsp;' . $group->name;
}, $DB->get_records_list('groups', 'id', explode(',', $override->groupids), 'id')));
}
$users = implode(', ', $users);
if ($users == '') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment