MDL-71215 core_user: User fields - remaining deprecated functions

This change removes references in code and comments to a few
deprecated functions that were accidentally missed in the larger
change.

The code changes only affect service_users.php. I made it support
custom user profile fields in this query, because it was easy
enough, rather than adding another TODO to fix later.
This commit is contained in:
sam marshall 2021-03-29 13:59:49 +01:00
parent f0eb6a5729
commit 611e2569aa
5 changed files with 12 additions and 14 deletions

View File

@ -1226,7 +1226,7 @@ class course_enrolment_manager {
* Please note that this function does not check capability for moodle/coures:viewhiddenuserfields
*
* @param object $user The user record
* @param array $extrafields The list of fields as returned from get_extra_user_fields used to determine which
* @param array $extrafields The list of fields as returned from \core_user\fields::get_identity_fields used to determine which
* additional fields may be displayed
* @param int $now The time used for lastaccess calculation
* @return array The fields to be displayed including userid, courseid, picture, firstname, lastcourseaccess, lastaccess and any

View File

@ -305,7 +305,7 @@ function users_search_sql($search, $u = 'u', $searchanywhere = true, array $extr
* - firstname
* - lastname
* - $DB->sql_fullname
* - those returned by get_extra_user_fields
* - those returned by \core_user\fields::get_identity_fields
*
* If named parameters are used (which is the default, and highly recommended),
* then the parameter names are like :usersortexactN, where N is an int.
@ -334,7 +334,7 @@ function users_search_sql($search, $u = 'u', $searchanywhere = true, array $extr
* @param string $usertablealias (optional) any table prefix for the {users} table. E.g. 'u'.
* @param string $search (optional) a current search string. If given,
* any exact matches to this string will be sorted first.
* @param context $context the context we are in. Use by get_extra_user_fields.
* @param context $context the context we are in. Used by \core_user\fields::get_identity_fields.
* Defaults to $PAGE->context.
* @return array with two elements:
* string SQL fragment to use in the ORDER BY clause. For example, "firstname, lastname".

View File

@ -482,7 +482,7 @@ class quiz_overview_report extends quiz_attempts_report {
*
* Given an array of attempts, it regrades them all, or does a dry run.
* Each object in the attempts array must be a row from the quiz_attempts
* table, with the get_all_user_name_fields from the user table joined in.
* table, with the \core_user\fields::for_name() fields from the user table joined in.
* In addition, if $attempt->regradeonlyslots is set, then only those slots
* are regraded, otherwise all slots are regraded.
*

View File

@ -288,21 +288,19 @@ class webservice {
$params = array($CFG->siteguest, $serviceid);
$namefields = get_all_user_name_fields(true, 'u');
$userfields = \core_user\fields::for_identity(context_system::instance())->with_name()->excluding('id');
$fieldsql = $userfields->get_sql('u');
foreach (get_extra_user_fields(context_system::instance()) as $extrafield) {
$namefields .= ',u.' . $extrafield;
}
$sql = " SELECT u.id as id, esu.id as serviceuserid, {$namefields},
$sql = " SELECT u.id as id, esu.id as serviceuserid {$fieldsql->selects},
esu.iprestriction as iprestriction, esu.validuntil as validuntil,
esu.timecreated as timecreated
FROM {user} u, {external_services_users} esu
FROM {user} u
JOIN {external_services_users} esu ON esu.userid = u.id
{$fieldsql->joins}
WHERE u.id <> ? AND u.deleted = 0 AND u.confirmed = 1
AND esu.userid = u.id
AND esu.externalserviceid = ?";
$users = $DB->get_records_sql($sql, $params);
$users = $DB->get_records_sql($sql, array_merge($fieldsql->params, $params));
return $users;
}

View File

@ -106,7 +106,7 @@ class core_webservice_renderer extends plugin_renderer_base {
global $CFG;
$listitems = [];
$extrafields = get_extra_user_fields(context_system::instance());
$extrafields = \core_user\fields::get_identity_fields(context_system::instance());
foreach ($users as $user) {
$settingsurl = new moodle_url('/admin/webservice/service_user_settings.php',