Merge branch 'MDL-82475-404' of https://github.com/paulholden/moodle into MOODLE_404_STABLE

This commit is contained in:
Jun Pataleta 2024-11-28 13:19:08 +08:00
commit 83c6906e75
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
2 changed files with 22 additions and 6 deletions

View File

@ -155,8 +155,9 @@ class user_profile_fields {
$columnfieldsql = $DB->sql_order_by_text($columnfieldsql, 1024);
}
$columns[] = (new column(
'profilefield_' . core_text::strtolower($profilefield->field->shortname),
$columnname = 'profilefield_' . core_text::strtolower($profilefield->field->shortname);
$columns[$columnname] = (new column(
$columnname,
new lang_string('customfieldcolumn', 'core_reportbuilder', $profilefield->display_name(false)),
$this->entityname
))
@ -176,7 +177,7 @@ class user_profile_fields {
->set_is_available($profilefield->is_visible());
}
return $columns;
return array_values($columns);
}
/**
@ -221,9 +222,10 @@ class user_profile_fields {
break;
}
$filtername = 'profilefield_' . core_text::strtolower($profilefield->field->shortname);
$filter = (new filter(
$classname,
'profilefield_' . core_text::strtolower($profilefield->field->shortname),
$filtername,
new lang_string('customfieldcolumn', 'core_reportbuilder', $profilefield->display_name(false)),
$this->entityname,
$fieldsql,
@ -238,10 +240,10 @@ class user_profile_fields {
$filter->set_options_callback(fn(): array => $profilefield->options);
}
$filters[] = $filter;
$filters[$filtername] = $filter;
}
return $filters;
return array_values($filters);
}
/**

View File

@ -91,6 +91,13 @@ class user_profile_fields_test extends core_reportbuilder_testcase {
$userentity->get_entity_name(),
))->get_columns();
// Create a field which will duplicate one of the subsequently generated fields (case-insensitive shortname).
$this->getDataGenerator()->create_custom_profile_field([
'shortname' => 'CHECKBOX',
'name' => 'Duplicate checkbox field',
'datatype' => 'checkbox',
]);
// Add new custom profile fields.
$userprofilefields = $this->generate_userprofilefields();
@ -210,6 +217,13 @@ class user_profile_fields_test extends core_reportbuilder_testcase {
$userentity->get_entity_name(),
))->get_filters();
// Create a field which will duplicate one of the subsequently generated fields (case-insensitive shortname).
$this->getDataGenerator()->create_custom_profile_field([
'shortname' => 'CHECKBOX',
'name' => 'Duplicate checkbox field',
'datatype' => 'checkbox',
]);
// Add new custom profile fields.
$userprofilefields = $this->generate_userprofilefields();