MDL-82512 files: Add Author filter to files Report Builder entity

This commit is contained in:
David Carrillo
2024-07-19 17:09:58 +02:00
parent 554a790bf0
commit 730c5413ce
2 changed files with 16 additions and 0 deletions
@@ -393,6 +393,16 @@ class file extends base {
return $mimetypes;
});
// Author.
$filters[] = (new filter(
text::class,
'author',
new lang_string('author', 'core_repository'),
$this->get_entity_name(),
"{$filesalias}.author"
))
->add_joins($this->get_joins());
// License (consider null = 'unknown/license not specified' for filtering purposes).
$filters[] = (new filter(
select::class,
@@ -231,6 +231,12 @@ final class files_test extends core_reportbuilder_testcase {
'file:type_operator' => select::EQUAL_TO,
'file:type_value' => 'image/png',
], 0],
'Filter author' => ['file:author', [
'file:author_operator' => text::IS_EMPTY,
], 4],
'Filter author (non match)' => ['file:author', [
'file:author_operator' => text::IS_NOT_EMPTY,
], 0],
'Filter license' => ['file:license', [
'file:license_operator' => select::EQUAL_TO,
'file:license_value' => 'unknown',