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_comment\reportbuilder\datasource; 20 21 use core_reportbuilder\datasource; 22 use core_reportbuilder\local\entities\user; 23 use core_comment\reportbuilder\local\entities\comment; 24 25 /** 26 * Comments datasource 27 * 28 * @package core_comment 29 * @copyright 2022 Paul Holden <paulh@moodle.com> 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 */ 32 class comments extends datasource { 33 34 /** 35 * Return user friendly name of the report source 36 * 37 * @return string 38 */ 39 public static function get_name(): string { 40 return get_string('comments', 'core_comment'); 41 } 42 43 /** 44 * Initialise report 45 */ 46 protected function initialise(): void { 47 $commententity = new comment(); 48 $commentalias = $commententity->get_table_alias('comments'); 49 50 $this->set_main_table('comments', $commentalias); 51 52 $this->add_entity($commententity); 53 54 // Join the user entity to the comment userid (author). 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 = {$commentalias}.userid")); 59 60 // Add report elements from each of the entities we added to the report. 61 $this->add_all_from_entities(); 62 } 63 64 /** 65 * Return the columns that will be added to the report upon creation 66 * 67 * @return string[] 68 */ 69 public function get_default_columns(): array { 70 return [ 71 'comment:context', 72 'comment:content', 73 'user:fullname', 74 'comment:timecreated', 75 ]; 76 } 77 78 /** 79 * Return the filters that will be added to the report upon creation 80 * 81 * @return string[] 82 */ 83 public function get_default_filters(): array { 84 return [ 85 'comment:content', 86 ]; 87 } 88 89 /** 90 * Return the conditions that will be added to the report upon creation 91 * 92 * @return string[] 93 */ 94 public function get_default_conditions(): array { 95 return [ 96 'user:fullname', 97 ]; 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body