From 20280c0405b80862c3c8bf429bda3c8617334096 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 8 Feb 2023 21:48:52 +0000 Subject: [PATCH] MDL-77180 customfield: allow entry of formatted category names. Change the param type of the category name when editing to allow for entry of multilang tags, the formatting of which is already supported when returning category name. Co-authored-by: Hiroto Kagotani --- customfield/classes/api.php | 2 +- customfield/classes/handler.php | 2 +- customfield/lib.php | 2 +- customfield/upgrade.txt | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/customfield/classes/api.php b/customfield/classes/api.php index 6ebce70d304..08e744ae4dc 100644 --- a/customfield/classes/api.php +++ b/customfield/classes/api.php @@ -254,7 +254,7 @@ class api { $category->get_formatted_name(), $category->get('name'), get_string('editcategoryname', 'core_customfield'), - get_string('newvaluefor', 'core_form', format_string($category->get('name'))) + get_string('newvaluefor', 'core_form', $category->get_formatted_name()) ); } diff --git a/customfield/classes/handler.php b/customfield/classes/handler.php index de75119aea0..1a44127854d 100644 --- a/customfield/classes/handler.php +++ b/customfield/classes/handler.php @@ -638,7 +638,7 @@ abstract class handler { foreach ($fieldswithdata as $data) { $categoryid = $data->get_field()->get_category()->get('id'); if ($categoryid != $lastcategoryid) { - $categoryname = format_string($data->get_field()->get_category()->get('name')); + $categoryname = $data->get_field()->get_category()->get_formatted_name(); // Load category header lang string if specified. if (!empty($headerlangidentifier)) { diff --git a/customfield/lib.php b/customfield/lib.php index 0c3986d6406..f9aab27eabd 100644 --- a/customfield/lib.php +++ b/customfield/lib.php @@ -42,7 +42,7 @@ function core_customfield_inplace_editable($itemtype, $itemid, $newvalue) { if (!$handler->can_configure()) { throw new moodle_exception('nopermissionconfigure', 'core_customfield'); } - $newvalue = clean_param($newvalue, PARAM_NOTAGS); + $newvalue = clean_param($newvalue, PARAM_TEXT); $handler->rename_category($category, $newvalue); return \core_customfield\api::get_category_inplace_editable($category, true); } diff --git a/customfield/upgrade.txt b/customfield/upgrade.txt index ae20f2d948f..73d2537a7ab 100644 --- a/customfield/upgrade.txt +++ b/customfield/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in /customfield/*, Information provided here is intended especially for developers. +=== 4.3 === +* Field categories are now consistently of type `PARAM_TEXT`, ensure instance `get_formatted_name()` helper is used + during output + === 4.2 === * The `\customfield_select\field_controller::get_options_array` method, deprecated since 3.10, has been removed, use the field instance `get_options` method instead