MDL-86575 cohort: format cohort names in external service return data.

This commit is contained in:
Paul Holden
2025-09-07 19:30:06 +02:00
parent 70de23e219
commit 2d6dad4a32
+6
View File
@@ -145,6 +145,8 @@ class core_cohort_external extends external_api {
$cohort->id = cohort_add_cohort($cohort);
$cohort->name = \core_external\util::format_string($cohort->name, $context);
list($cohort->description, $cohort->descriptionformat) =
\core_external\util::format_text($cohort->description, $cohort->descriptionformat,
$context, 'cohort', 'description', $cohort->id);
@@ -284,6 +286,8 @@ class core_cohort_external extends external_api {
throw new required_capability_exception($context, 'moodle/cohort:view', 'nopermissions', '');
}
$cohort->name = \core_external\util::format_string($cohort->name, $context);
// Only return theme when $CFG->allowcohortthemes is enabled.
if (!empty($cohort->theme) && empty($CFG->allowcohortthemes)) {
$cohort->theme = null;
@@ -421,6 +425,8 @@ class core_cohort_external extends external_api {
foreach ($results as $key => $cohort) {
$cohortcontext = context::instance_by_id($cohort->contextid);
$cohort->name = \core_external\util::format_string($cohort->name, $cohortcontext);
// Only return theme when $CFG->allowcohortthemes is enabled.
if (!empty($cohort->theme) && empty($CFG->allowcohortthemes)) {
$cohort->theme = null;