From f657fe5ded5334710df47080638e83a024e4d065 Mon Sep 17 00:00:00 2001 From: TamaroWalter Date: Fri, 17 May 2024 16:12:44 +0200 Subject: [PATCH] adapt external class for moodle 401 --- classes/external.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/classes/external.php b/classes/external.php index fc9ed3a..674e237 100644 --- a/classes/external.php +++ b/classes/external.php @@ -80,17 +80,18 @@ public static function record_usersettings_returns(): external_value { */ public static function record_usersettings($userid, $timefilterpast, $timefilterfuture, $basicletter, $completionletter, $postletter): bool { - global $DB; + global $DB, $CFG; // Parameter validation. - $params = self::validate_parameters(self::record_usersettings_parameters(), [ - 'userid' => $userid, - 'timefilterpast' => $timefilterpast, - 'timefilterfuture' => $timefilterfuture, - 'basicletter' => $basicletter, - 'completionletter' => $completionletter, - 'postletter' => $postletter, - ]); + if ($CFG->branch >= 402) { + $params = self::validate_parameters(self::record_usersettings_parameters(), [ + 'userid' => $userid, 'timefilterpast' => $timefilterpast, 'timefilterfuture' => $timefilterfuture, + 'basicletter' => $basicletter, 'completionletter' => $completionletter, 'postletter' => $postletter, + ]); + } else { + $params = ['userid' => $userid, 'timefilterpast' => $timefilterpast, 'timefilterfuture' => $timefilterfuture, + 'basicletter' => $basicletter, 'completionletter' => $completionletter, 'postletter' => $postletter, ]; + } // Check if the user already has a record in the database. if ($records = $DB->get_records('block_townsquare_preferences', ['userid' => $userid])) {