mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-76873 reportbuilder: correct checks for profile field visibility.
This commit is contained in:
parent
8503f2cfd8
commit
65c4ae7bda
@ -109,28 +109,30 @@ class user extends base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns column that corresponds to the given identity field
|
||||
* Returns column that corresponds to the given identity field, profile field identifiers will be converted to those
|
||||
* used by the {@see user_profile_fields} helper
|
||||
*
|
||||
* @param string $identityfield Field from the user table, or the shortname of a custom profile field
|
||||
* @param string $identityfield Field from the user table, or a custom profile field
|
||||
* @return column
|
||||
*/
|
||||
public function get_identity_column(string $identityfield): column {
|
||||
if (preg_match("/^profile_field_(?<shortname>.*)$/", $identityfield, $matches)) {
|
||||
$identityfield = 'profilefield_' . $matches['shortname'];
|
||||
if (preg_match(fields::PROFILE_FIELD_REGEX, $identityfield, $matches)) {
|
||||
$identityfield = 'profilefield_' . $matches[1];
|
||||
}
|
||||
|
||||
return $this->get_column($identityfield);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filter that corresponds to the given identity field
|
||||
* Returns filter that corresponds to the given identity field, profile field identifiers will be converted to those
|
||||
* used by the {@see user_profile_fields} helper
|
||||
*
|
||||
* @param string $identityfield Field from the user table, or the shortname of a custom profile field
|
||||
* @param string $identityfield Field from the user table, or a custom profile field
|
||||
* @return filter
|
||||
*/
|
||||
public function get_identity_filter(string $identityfield): filter {
|
||||
if (preg_match("/^profile_field_(?<shortname>.*)$/", $identityfield, $matches)) {
|
||||
$identityfield = 'profilefield_' . $matches['shortname'];
|
||||
if (preg_match(fields::PROFILE_FIELD_REGEX, $identityfield, $matches)) {
|
||||
$identityfield = 'profilefield_' . $matches[1];
|
||||
}
|
||||
|
||||
return $this->get_filter($identityfield);
|
||||
|
@ -74,8 +74,8 @@ class user_profile_fields {
|
||||
* @return profile_field_base[]
|
||||
*/
|
||||
private function get_user_profile_fields(): array {
|
||||
return array_filter(profile_get_user_fields_with_data(0), static function($profilefield): bool {
|
||||
return (int)$profilefield->field->visible === (int)PROFILE_VISIBLE_ALL;
|
||||
return array_filter(profile_get_user_fields_with_data(0), static function(profile_field_base $profilefield): bool {
|
||||
return $profilefield->is_visible();
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user