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\permission; 24 use core_reportbuilder\local\models\schedule; 25 26 defined('MOODLE_INTERNAL') || die; 27 28 global $CFG; 29 require_once("{$CFG->libdir}/external/externallib.php"); 30 31 /** 32 * Schedule name editable component 33 * 34 * @package core_reportbuilder 35 * @copyright 2021 Paul Holden <paulh@moodle.com> 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class schedule_name_editable extends inplace_editable { 39 40 /** 41 * Class constructor 42 * 43 * @param int $scheduleid 44 * @param schedule|null $schedule 45 */ 46 public function __construct(int $scheduleid, ?schedule $schedule = null) { 47 if ($schedule === null) { 48 $schedule = new schedule($scheduleid); 49 } 50 51 $report = $schedule->get_report(); 52 $editable = permission::can_edit_report($report); 53 54 $displayvalue = $schedule->get_formatted_name($report->get_context()); 55 56 parent::__construct('core_reportbuilder', 'schedulename', $schedule->get('id'), $editable, $displayvalue, 57 $schedule->get('name'), get_string('editschedulename', 'core_reportbuilder')); 58 } 59 60 /** 61 * Update schedule persistent and return self, called from inplace_editable callback 62 * 63 * @param int $scheduleid 64 * @param string $value 65 * @return self 66 */ 67 public static function update(int $scheduleid, string $value): self { 68 $schedule = new schedule($scheduleid); 69 70 $report = $schedule->get_report(); 71 72 core_external::validate_context($report->get_context()); 73 permission::require_can_edit_report($report); 74 75 $value = trim(clean_param($value, PARAM_TEXT)); 76 if ($value !== '') { 77 $schedule 78 ->set('name', $value) 79 ->update(); 80 } 81 82 return new self(0, $schedule); 83 } 84 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body