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

View File

@ -125,8 +125,9 @@ class user_profile_fields {
END";
}
$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
))
@ -152,7 +153,7 @@ class user_profile_fields {
->set_is_available($profilefield->is_visible());
}
return $columns;
return array_values($columns);
}
/**
@ -210,9 +211,10 @@ class user_profile_fields {
$userinfoparams[$paramdefault] = $fielddefault;
}
$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,
$userinfosql,
@ -227,10 +229,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

@ -87,6 +87,13 @@ final 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();
@ -207,6 +214,13 @@ final 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();