Skip to content

Commit

Permalink
MDL-84226 user: add report entity filter for user picture presence.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jan 16, 2025
1 parent f4f1666 commit a743f4c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ filterbyname,core_grades
filterfirstactive,core_grades
filterlastactive,core_grades
privacy:metadata:preference:reportfilter,core_reportbuilder
userpicture,core_reportbuilder
noreplybouncemessage,core
noreplybouncesubject,core
configgeneralquestionbank,core_backup
Expand Down
2 changes: 1 addition & 1 deletion lang/en/reportbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@
$string['userfullnamewithpicture'] = 'Full name with picture';
$string['userfullnamewithpicturelink'] = 'Full name with picture and link';
$string['usermodified'] = 'Modified by';
$string['userpicture'] = 'User picture';
$string['userselect'] = 'Select user';
$string['viewreport'] = 'View report';

Expand All @@ -302,3 +301,4 @@

// Deprecated since Moodle 5.0.
$string['privacy:metadata:preference:reportfilter'] = 'Stored report filter values';
$string['userpicture'] = 'User picture';
12 changes: 11 additions & 1 deletion reportbuilder/classes/local/entities/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ protected function get_all_columns(): array {
// Picture column.
$columns[] = (new column(
'picture',
new lang_string('userpicture', 'core_reportbuilder'),
new lang_string('picture'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
Expand Down Expand Up @@ -505,6 +505,16 @@ protected function get_all_filters(): array {
))
->add_joins($this->get_joins());

// Picture filter.
$filters[] = (new filter(
boolean_select::class,
'picture',
new lang_string('picture'),
$this->get_entity_name(),
"CASE WHEN {$tablealias}.picture > 0 THEN 1 ELSE 0 END",
))
->add_joins($this->get_joins());

// User fields filters.
$fields = $this->get_user_fields();
foreach ($fields as $field => $name) {
Expand Down
6 changes: 6 additions & 0 deletions user/tests/reportbuilder/datasource/users_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ public static function datasource_filters_provider(): array {
'user:fullname_operator' => text::CONTAINS,
'user:fullname_value' => 'Alfie',
], false],
'Filter picture' => ['user:picture', [
'user:picture_operator' => boolean_select::NOT_CHECKED,
], true],
'Filter picture (no match)' => ['user:picture', [
'user:picture_operator' => boolean_select::CHECKED,
], false],
'Filter firstname' => ['user:firstname', [
'user:firstname_operator' => text::IS_EQUAL_TO,
'user:firstname_value' => 'Zoe',
Expand Down

0 comments on commit a743f4c

Please sign in to comment.