MDL-63264 enrol: retrieve additional welcome message contact data.

The `maildisplay` field is required to determine from whom to send
the welcome message.

Co-authored-by: Zak Risha <zjrisha@gmail.com>
This commit is contained in:
Paul Holden 2024-11-12 19:48:15 +00:00
parent 485130d7c5
commit 88ef13a747
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -3608,14 +3608,15 @@ abstract class enrol_plugin {
$rusers = [];
if (!empty($CFG->coursecontact)) {
$croles = explode(',', $CFG->coursecontact);
[$sort, $sortparams] = users_order_by_sql('u');
[$sort] = users_order_by_sql('u');
// We only use the first user.
$i = 0;
do {
$userfieldsapi = \core_user\fields::for_name();
$allnames = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
$rusers = get_role_users($croles[$i], $context, true, 'u.id, u.confirmed, u.username, '. $allnames . ',
u.email, r.sortorder, ra.id AS raid', 'r.sortorder, ra.id ASC, ' . $sort, null, '', '', '', '', $sortparams);
$rusers = get_role_users($croles[$i], $context, true,
"u.id, u.confirmed, u.username, {$allnames}, u.email, u.maildisplay, r.sortorder, ra.id AS raid",
"r.sortorder, ra.id ASC, {$sort}");
$i++;
} while (empty($rusers) && !empty($croles[$i]));
}