From 2b6d7d300aa33e170b54c39d4652eb078acddcf6 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 21 Apr 2023 11:38:19 +0100 Subject: [PATCH] MDL-71413 user: final removal of deprecated profile field methods. --- lib/deprecatedlib.php | 21 +++++++++ user/profile/definelib.php | 93 -------------------------------------- user/profile/lib.php | 23 ---------- user/upgrade.txt | 7 +++ 4 files changed, 28 insertions(+), 116 deletions(-) diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 3236a3e2738..ed4802ccbcf 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -3351,6 +3351,27 @@ function get_all_user_name_fields($returnsql = false, $tableprefix = null, $pref return $alternatenames; } +/** + * @deprecated since Moodle 3.11 MDL-71051 + */ +function profile_display_fields() { + throw new coding_exception(__FUNCTION__ . '() has been removed.'); +} + +/** + * @deprecated since Moodle 3.11 MDL-71051 + */ +function profile_edit_category() { + throw new coding_exception(__FUNCTION__ . '() has been removed.'); +} + +/** + * @deprecated since Moodle 3.11 MDL-71051 + */ +function profile_edit_field() { + throw new coding_exception(__FUNCTION__ . '() has been removed.'); +} + /** * Update a subscription from the form data in one of the rows in the existing subscriptions table. * diff --git a/user/profile/definelib.php b/user/profile/definelib.php index efd03c4d4db..405e52e822d 100644 --- a/user/profile/definelib.php +++ b/user/profile/definelib.php @@ -509,52 +509,6 @@ function profile_save_category(stdClass $data): void { profile_purge_user_fields_cache(); } -/** - * Edit a category - * - * @deprecated since Moodle 3.11 MDL-71051 - please do not use this function any more. - * @todo MDL-71413 This will be deleted in Moodle 4.3. - * @see profile_save_category() - * - * @param int $id - * @param string $redirect - */ -function profile_edit_category($id, $redirect) { - global $DB, $OUTPUT, $CFG; - - debugging('Function profile_edit_category() is deprecated without replacement, see also profile_save_category()', - DEBUG_DEVELOPER); - - $categoryform = new \core_user\form\profile_category_form(); - - if ($category = $DB->get_record('user_info_category', array('id' => $id))) { - $categoryform->set_data($category); - } - - if ($categoryform->is_cancelled()) { - redirect($redirect); - } else { - if ($data = $categoryform->get_data()) { - profile_save_category($data); - redirect($redirect); - } - - if (empty($id)) { - $strheading = get_string('profilecreatenewcategory', 'admin'); - } else { - $strheading = get_string('profileeditcategory', 'admin', format_string($category->name)); - } - - // Print the page. - echo $OUTPUT->header(); - echo $OUTPUT->heading($strheading); - $categoryform->display(); - echo $OUTPUT->footer(); - die; - } - -} - /** * Save updated field definition or create a new field * @@ -596,53 +550,6 @@ function profile_save_field(stdClass $data, array $editors): void { profile_reorder_categories(); } -/** - * Edit a profile field. - * - * @deprecated since Moodle 3.11 MDL-71051 - please do not use this function any more. - * @todo MDL-71413 This will be deleted in Moodle 4.3. - * @see profile_save_field() - * - * @param int $id - * @param string $datatype - * @param string $redirect - */ -function profile_edit_field($id, $datatype, $redirect) { - global $OUTPUT, $PAGE; - - debugging('Function profile_edit_field() is deprecated without replacement, see also profile_save_field()', - DEBUG_DEVELOPER); - - $fieldform = new \core_user\form\profile_field_form(); - $fieldform->set_data_for_dynamic_submission(); - - if ($fieldform->is_cancelled()) { - redirect($redirect); - - } else { - if ($data = $fieldform->get_data()) { - profile_save_field($data, $fieldform->editors()); - redirect($redirect); - } - - $datatypes = profile_list_datatypes(); - - if (empty($id)) { - $strheading = get_string('profilecreatenewfield', 'admin', $datatypes[$datatype]); - } else { - $strheading = get_string('profileeditfield', 'admin', format_string($fieldform->get_field_record()->name)); - } - - // Print the page. - $PAGE->navbar->add($strheading); - echo $OUTPUT->header(); - echo $OUTPUT->heading($strheading); - $fieldform->display(); - echo $OUTPUT->footer(); - die; - } -} - /** * Purge the cache for the user profile fields */ diff --git a/user/profile/lib.php b/user/profile/lib.php index b6a2cc21812..ca249d22355 100644 --- a/user/profile/lib.php +++ b/user/profile/lib.php @@ -744,29 +744,6 @@ function profile_save_data(stdClass $usernew): void { } } -/** - * Display profile fields. - * - * @deprecated since Moodle 3.11 MDL-71051 - please do not use this function any more. - * @todo MDL-71413 This will be deleted in Moodle 4.3. - * - * @param int $userid - */ -function profile_display_fields($userid) { - debugging('Function profile_display_fields() is deprecated because it is no longer used and will be '. - 'removed in future versions of Moodle', DEBUG_DEVELOPER); - - $categories = profile_get_user_fields_with_data_by_category($userid); - foreach ($categories as $categoryid => $fields) { - foreach ($fields as $formfield) { - if ($formfield->is_visible() and !$formfield->is_empty()) { - echo html_writer::tag('dt', format_string($formfield->field->name)); - echo html_writer::tag('dd', $formfield->display_data()); - } - } - } -} - /** * Retrieves a list of profile fields that must be displayed in the sign-up form. * diff --git a/user/upgrade.txt b/user/upgrade.txt index 333c0bd5218..2edf699e1c8 100644 --- a/user/upgrade.txt +++ b/user/upgrade.txt @@ -1,5 +1,12 @@ This files describes API changes for code that uses the user API. +=== 4.3 === + +* The following previously deprecated methods have been removed and can no longer be used: + - `profile_display_fields` + - `profile_edit_category` + - `profile_edit_field` + === 4.2 === * Added get_internalfield_list() and get_internalfields() in the user_field_mapping class.