See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [Versions 401 and 402] [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_reportbuilder\output; 20 21 use core_external; 22 use core\output\inplace_editable; 23 use core_reportbuilder\manager; 24 use core_reportbuilder\permission; 25 use core_reportbuilder\local\models\column; 26 27 defined('MOODLE_INTERNAL') || die; 28 29 global $CFG; 30 require_once("{$CFG->libdir}/external/externallib.php"); 31 32 /** 33 * Column heading editable component 34 * 35 * @package core_reportbuilder 36 * @copyright 2021 Paul Holden <paulh@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class column_heading_editable extends inplace_editable { 40 41 /** 42 * Class constructor 43 * 44 * @param int $columnid 45 * @param column|null $column 46 */ 47 public function __construct(int $columnid, ?column $column = null) { 48 if ($column === null) { 49 $column = new column($columnid); 50 } 51 52 $report = $column->get_report(); 53 $editable = permission::can_edit_report($report); 54 55 $columninstance = manager::get_report_from_persistent($report) 56 ->get_column($column->get('uniqueidentifier')); 57 58 // Use column defined title if custom heading not set. 59 if ('' !== $value = (string) $column->get('heading')) { 60 $displayvalue = $column->get_formatted_heading($report->get_context()); 61 } else { 62 $displayvalue = $value = $columninstance->get_title(); 63 } 64 65 parent::__construct('core_reportbuilder', 'columnheading', $column->get('id'), $editable, $displayvalue, $value, 66 get_string('renamecolumn', 'core_reportbuilder', $columninstance->get_title())); 67 } 68 69 /** 70 * Update column persistent and return self, called from inplace_editable callback 71 * 72 * @param int $columnid 73 * @param string $value 74 * @return self 75 */ 76 public static function update(int $columnid, string $value): self { 77 $column = new column($columnid); 78 79 $report = $column->get_report(); 80 81 core_external::validate_context($report->get_context()); 82 permission::require_can_edit_report($report); 83 84 $value = clean_param($value, PARAM_TEXT); 85 $column 86 ->set('heading', trim($value)) 87 ->update(); 88 89 return new self(0, $column); 90 } 91 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body