Skip to content

#247 [CONTRIB-9748] The deprecated function get_all_user_name fields should be replaced if possible #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: MOODLE_4x_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions components/filters/enrolledstudents/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,18 @@ public function print_filter(MoodleQuickForm $mform, $formdata = false): void {
$nameformat = get_string('fullnamedisplay');
}

$sort = implode(',', order_in_string(get_all_user_name_fields(), $nameformat));
if (class_exists('\core_user\fields')) {
$namesArray = \core_user\fields::get_name_fields();
$allnames = \core_user\fields::for_name()->get_sql('', false, '', '', false)->selects;
} else {
$namesArray = get_all_user_name_fields();
$allnames = get_all_user_name_fields(true, 'u');
}
$sort = implode(',', order_in_string($namesArray, $nameformat));

[$usql, $params] = $remotedb->get_in_or_equal($enrolledstudentslist);
$enrolledstudents =
$remotedb->get_records_select('user', "id " . $usql, $params, $sort, 'id,' . get_all_user_name_fields(true));
$remotedb->get_records_select('user', "id " . $usql, $params, $sort, 'id,' . $allnames);

foreach ($enrolledstudents as $c) {
$enrolledstudentsoptions[$c->id] = fullname($c);
Expand Down
11 changes: 9 additions & 2 deletions components/filters/user/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,17 @@ public function print_filter(MoodleQuickForm $mform, $formdata = false): void {
$nameformat = get_string('fullnamedisplay');
}

$sort = implode(',', order_in_string(get_all_user_name_fields(), $nameformat));
if (class_exists('\core_user\fields')) {
$namesArray = \core_user\fields::get_name_fields();
$allnames = \core_user\fields::for_name()->get_sql('', false, '', '', false)->selects;
} else {
$namesArray = get_all_user_name_fields();
$allnames = get_all_user_name_fields(true, 'u');
}
$sort = implode(',', order_in_string($namesArray, $nameformat));

[$usql, $params] = $remotedb->get_in_or_equal($userlist);
$users = $remotedb->get_records_select('user', "id " . $usql, $params, $sort, 'id,' . get_all_user_name_fields(true));
$users = $remotedb->get_records_select('user', "id " . $usql, $params, $sort, 'id,' . $allnames);

foreach ($users as $c) {
$useroptions[$c->id] = fullname($c);
Expand Down
11 changes: 9 additions & 2 deletions components/filters/users/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,17 @@ public function print_filter(MoodleQuickForm $mform, $formdata = false): void {
$nameformat = get_string('fullnamedisplay');
}

$sort = implode(',', order_in_string(get_all_user_name_fields(), $nameformat));
if (class_exists('\core_user\fields')) {
$namesArray = \core_user\fields::get_name_fields();
$allnames = \core_user\fields::for_name()->get_sql('', false, '', '', false)->selects;
} else {
$namesArray = get_all_user_name_fields();
$allnames = get_all_user_name_fields(true, 'u');
}
$sort = implode(',', order_in_string($namesArray, $nameformat));

[$usql, $params] = $remotedb->get_in_or_equal($userslist);
$users = $remotedb->get_records_select('user', "id " . $usql, $params, $sort, 'id,' . get_all_user_name_fields(true));
$users = $remotedb->get_records_select('user', "id " . $usql, $params, $sort, 'id,' . $allnames);

foreach ($users as $c) {
$usersoptions[$c->id] = fullname($c);
Expand Down