See Release Notes
Long Term Support Release
Differences Between: [Versions 401 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_tag\reportbuilder\datasource; 20 21 use lang_string; 22 use core_reportbuilder\datasource; 23 use core_reportbuilder\local\entities\user; 24 use core_tag\reportbuilder\local\entities\{collection, tag, instance}; 25 26 /** 27 * Tags datasource 28 * 29 * @package core_tag 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 tags 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('tags', 'core_tag'); 42 } 43 44 /** 45 * Initialise report 46 */ 47 protected function initialise(): void { 48 $collectionentity = new collection(); 49 50 $collectionalias = $collectionentity->get_table_alias('tag_coll'); 51 $this->set_main_table('tag_coll', $collectionalias); 52 53 $this->add_entity($collectionentity); 54 55 // Join tag entity to collection. 56 $tagentity = new tag(); 57 $tagalias = $tagentity->get_table_alias('tag'); 58 $this->add_entity($tagentity 59 ->add_join("LEFT JOIN {tag} {$tagalias} ON {$tagalias}.tagcollid = {$collectionalias}.id") 60 ); 61 62 // Join instance entity to tag. 63 $instanceentity = new instance(); 64 $instancealias = $instanceentity->get_table_alias('tag_instance'); 65 $this->add_entity($instanceentity 66 ->add_joins($tagentity->get_joins()) 67 ->add_join("LEFT JOIN {tag_instance} {$instancealias} ON {$instancealias}.tagid = {$tagalias}.id") 68 ); 69 70 // Join user entity to represent the tag author. 71 $userentity = (new user()) 72 ->set_entity_title(new lang_string('tagauthor', 'core_tag')); 73 $useralias = $userentity->get_table_alias('user'); 74 $this->add_entity($userentity 75 ->add_joins($tagentity->get_joins()) 76 ->add_join("LEFT JOIN {user} {$useralias} ON {$useralias}.id = {$tagalias}.userid") 77 ); 78 79 // Add report elements from each of the entities we added to the report. 80 $this->add_all_from_entities(); 81 } 82 83 /** 84 * Return the columns that will be added to the report upon creation 85 * 86 * @return string[] 87 */ 88 public function get_default_columns(): array { 89 return [ 90 'collection:name', 91 'tag:namewithlink', 92 'tag:standard', 93 'instance:context', 94 ]; 95 } 96 97 /** 98 * Return the filters that will be added to the report upon creation 99 * 100 * @return string[] 101 */ 102 public function get_default_filters(): array { 103 return [ 104 'tag:name', 105 'tag:standard', 106 ]; 107 } 108 109 /** 110 * Return the conditions that will be added to the report upon creation 111 * 112 * @return string[] 113 */ 114 public function get_default_conditions(): array { 115 return [ 116 'collection:name', 117 ]; 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body