From 44c213bd07d02c0843328b2db04f8dda9763f80e Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 10 May 2021 09:42:39 +1200 Subject: [PATCH] Replace deprecated function calls. --- classes/form/export.php | 4 +++- classes/form/tempmerge.php | 3 ++- classes/structure.php | 2 +- locallib.php | 8 ++++---- messageselect.php | 4 +++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/classes/form/export.php b/classes/form/export.php index 177c526..cf415a4 100644 --- a/classes/form/export.php +++ b/classes/form/export.php @@ -60,7 +60,9 @@ class export extends \moodleform { } // Restrict the export to the selected users. - $namefields = get_all_user_name_fields(true, 'u'); + $userfieldsapi = \core_user\fields::for_name(); + $namefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects; + $allusers = get_enrolled_users($modcontext, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields); $userlist = array(); foreach ($allusers as $user) { diff --git a/classes/form/tempmerge.php b/classes/form/tempmerge.php index 8f24c92..972fba9 100644 --- a/classes/form/tempmerge.php +++ b/classes/form/tempmerge.php @@ -43,7 +43,8 @@ class tempmerge extends \moodleform { global $COURSE; $context = \context_course::instance($COURSE->id); - $namefields = get_all_user_name_fields(true, 'u'); + $userfieldsapi = \core_user\fields::for_name(); + $namefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects; $students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email', 'u.lastname, u.firstname', 0, 0, true); $partarray = array(); diff --git a/classes/structure.php b/classes/structure.php index 4cef5e9..c5b6396 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -909,7 +909,7 @@ class mod_attendance_structure { 'picture' => 0, 'type' => 'temporary', ); - $allfields = get_all_user_name_fields(); + $allfields = \core_user\fields::get_name_fields(); if (!empty($CFG->showuseridentity)) { $allfields = array_merge($allfields, explode(',', $CFG->showuseridentity)); } diff --git a/locallib.php b/locallib.php index 78a34c8..fb7c65b 100644 --- a/locallib.php +++ b/locallib.php @@ -1010,9 +1010,9 @@ function attendance_get_users_to_notify($courseids = array(), $orderby = '', $al // Exclude warnings that have already sent the max num. $having .= ' AND n.maxwarn > COUNT(DISTINCT ns.id) '; } - - $unames = get_all_user_name_fields(true).','; - $unames2 = get_all_user_name_fields(true, 'u').','; + $userfieldsapi = \core_user\fields::for_name(); + $unames = $userfieldsapi->get_sql('', false, '', '', false)->selects.','; + $unames2 = $userfieldsapi->get_sql('u', false, '', '', false)->selects.','; if (!empty($CFG->showuseridentity)) { $extrafields = explode(',', $CFG->showuseridentity); @@ -1089,7 +1089,7 @@ function attendance_template_variables($record) { '/%maxpoints%/' => $record->maxpoints, '/%percent%/' => $record->percent, ); - $extrauserfields = get_all_user_name_fields(); + $extrauserfields = \core_user\fields::get_name_fields(); foreach ($extrauserfields as $extra) { $templatevars['/%'.$extra.'%/'] = $record->$extra; } diff --git a/messageselect.php b/messageselect.php index d22075e..47a7792 100644 --- a/messageselect.php +++ b/messageselect.php @@ -80,7 +80,9 @@ $messagebody = $SESSION->emailselect[$id]['messagebody']; $count = 0; if ($data = data_submitted()) { require_sesskey(); - $namefields = get_all_user_name_fields(true); + $userfieldsapi = \core_user\fields::for_name(); + $namefields = $userfieldsapi->get_sql('', false, '', '', false)->selects; + foreach ($data as $k => $v) { if (preg_match('/^(user|teacher)(\d+)$/', $k, $m)) { if (!array_key_exists($m[2], $SESSION->emailto[$id])) {