diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index f7a2b4a59cd7d..7f7d023d752b9 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -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 diff --git a/lang/en/reportbuilder.php b/lang/en/reportbuilder.php index 32d6cbacfc30a..c18cf02131580 100644 --- a/lang/en/reportbuilder.php +++ b/lang/en/reportbuilder.php @@ -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'; @@ -302,3 +301,4 @@ // Deprecated since Moodle 5.0. $string['privacy:metadata:preference:reportfilter'] = 'Stored report filter values'; +$string['userpicture'] = 'User picture'; diff --git a/reportbuilder/classes/local/entities/user.php b/reportbuilder/classes/local/entities/user.php index 1bde11b0d9d6c..3458640a335ad 100644 --- a/reportbuilder/classes/local/entities/user.php +++ b/reportbuilder/classes/local/entities/user.php @@ -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()) @@ -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) { diff --git a/user/tests/reportbuilder/datasource/users_test.php b/user/tests/reportbuilder/datasource/users_test.php index 48501ae6bbabd..79b75005cc77d 100644 --- a/user/tests/reportbuilder/datasource/users_test.php +++ b/user/tests/reportbuilder/datasource/users_test.php @@ -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',