Differences Between: [Versions 402 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 declare(strict_types=1); 18 19 namespace core_files\reportbuilder\datasource; 20 21 use core_files\reportbuilder\local\entities\file; 22 use core_reportbuilder\datasource; 23 use core_reportbuilder\local\entities\user; 24 use core_reportbuilder\local\filters\boolean_select; 25 26 /** 27 * Files datasource 28 * 29 * @package core_files 30 * @copyright 2022 Paul Holden <paulh@moodle.com> 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class files extends datasource { 34 35 /** 36 * Return user friendly name of the report source 37 * 38 * @return string 39 */ 40 public static function get_name(): string { 41 return get_string('files'); 42 } 43 44 /** 45 * Initialise report 46 */ 47 protected function initialise(): void { 48 $fileentity = new file(); 49 $filesalias = $fileentity->get_table_alias('files'); 50 51 $this->set_main_table('files', $filesalias); 52 $this->add_entity($fileentity); 53 54 // Join the user entity. 55 $userentity = new user(); 56 $useralias = $userentity->get_table_alias('user'); 57 $this->add_entity($userentity 58 ->add_join("LEFT JOIN {user} {$useralias} ON {$useralias}.id = {$filesalias}.userid") 59 ); 60 61 // Add report elements from each of the entities we added to the report. 62 $this->add_all_from_entities(); 63 } 64 65 /** 66 * Return the columns that will be added to the report upon creation 67 * 68 * @return string[] 69 */ 70 public function get_default_columns(): array { 71 return [ 72 'file:context', 73 'user:fullname', 74 'file:name', 75 'file:type', 76 'file:size', 77 'file:timecreated', 78 ]; 79 } 80 81 /** 82 * Return the filters that will be added to the report upon creation 83 * 84 * @return string[] 85 */ 86 public function get_default_filters(): array { 87 return [ 88 'file:size', 89 'file:timecreated', 90 ]; 91 } 92 93 /** 94 * Return the conditions that will be added to the report upon creation 95 * 96 * @return string[] 97 */ 98 public function get_default_conditions(): array { 99 return ['file:directory']; 100 } 101 102 /** 103 * Return the condition values that will be set for the report upon creation 104 * 105 * @return array 106 */ 107 public function get_default_condition_values(): array { 108 return ['file:directory_operator' => boolean_select::NOT_CHECKED]; 109 } 110 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body