From c32a53a592f392ba3ad638d502ab23a79e0ae89e Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 7 May 2021 23:35:49 +1200 Subject: [PATCH] Convert to using new user field apis --- classes/form/export.php | 2 +- classes/structure.php | 7 ++----- renderer.php | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/classes/form/export.php b/classes/form/export.php index b47d77a..177c526 100644 --- a/classes/form/export.php +++ b/classes/form/export.php @@ -111,7 +111,7 @@ class export extends \moodleform { $checkedfields['ident[id]'] = true; } - $extrafields = get_extra_user_fields($modcontext); + $extrafields = \core_user\fields::for_identity($modcontext)->get_required_fields(); foreach ($extrafields as $field) { $ident[] =& $mform->createElement('checkbox', $field, '', get_string( $field)); $mform->setType($field, PARAM_NOTAGS); diff --git a/classes/structure.php b/classes/structure.php index 839bd33..4cef5e9 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -802,11 +802,8 @@ class mod_attendance_structure { global $DB; $fields = array('username' , 'idnumber' , 'institution' , 'department', 'city', 'country'); - // Get user identity fields if required - doesn't return original $fields array. - $extrafields = get_extra_user_fields($this->context, $fields); - $fields = array_merge($fields, $extrafields); - - $userfields = user_picture::fields('u', $fields); + $userf = \core_user\fields::for_identity($this->context)->with_userpic()->excluding(...$fields); + $userfields = $userf->get_sql('u', false, '', 'id', false)->selects; if (empty($this->pageparams->sort)) { $this->pageparams->sort = ATT_SORT_DEFAULT; diff --git a/renderer.php b/renderer.php index de86e03..4fefe99 100644 --- a/renderer.php +++ b/renderer.php @@ -2134,7 +2134,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $rows = array(); $bulkmessagecapability = has_capability('moodle/course:bulkmessaging', $this->page->context); - $extrafields = get_extra_user_fields($reportdata->att->context); + $extrafields = \core_user\fields::for_identity($reportdata->att->context)->get_required_fields(); $showextrauserdetails = $reportdata->pageparams->showextrauserdetails; $params = $reportdata->pageparams->get_significant_params(); $text = get_string('users');