See Release Notes
Long Term Support Release
Differences Between: [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\external\conditions; 20 21 use external_api; 22 use external_function_parameters; 23 use external_single_structure; 24 use external_value; 25 use core_reportbuilder\manager; 26 use core_reportbuilder\permission; 27 use core_reportbuilder\external\custom_report_conditions_exporter; 28 use core_reportbuilder\local\helpers\report; 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 global $CFG; 33 require_once("{$CFG->libdir}/externallib.php"); 34 35 /** 36 * External method for deleting report conditions 37 * 38 * @package core_reportbuilder 39 * @copyright 2021 Paul Holden <paulh@moodle.com> 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class delete extends external_api { 43 44 /** 45 * External method parameters 46 * 47 * @return external_function_parameters 48 */ 49 public static function execute_parameters(): external_function_parameters { 50 return new external_function_parameters([ 51 'reportid' => new external_value(PARAM_INT, 'Report ID'), 52 'conditionid' => new external_value(PARAM_INT, 'Condition ID'), 53 ]); 54 } 55 56 /** 57 * External method execution 58 * 59 * @param int $reportid 60 * @param int $conditionid 61 * @return array 62 */ 63 public static function execute(int $reportid, int $conditionid): array { 64 global $PAGE, $OUTPUT; 65 66 [ 67 'reportid' => $reportid, 68 'conditionid' => $conditionid, 69 ] = self::validate_parameters(self::execute_parameters(), [ 70 'reportid' => $reportid, 71 'conditionid' => $conditionid, 72 ]); 73 74 $report = manager::get_report_from_id($reportid); 75 76 self::validate_context($report->get_context()); 77 permission::require_can_edit_report($report->get_report_persistent()); 78 79 report::delete_report_condition($reportid, $conditionid); 80 81 // Set current URL and force bootstrap_renderer to initiate moodle page. 82 $PAGE->set_url('/'); 83 $OUTPUT->header(); 84 $PAGE->start_collecting_javascript_requirements(); 85 86 $exporter = new custom_report_conditions_exporter(null, ['report' => $report]); 87 88 $export = $exporter->export($PAGE->get_renderer('core')); 89 $export->javascript = $PAGE->requires->get_end_code(); 90 91 return (array) $export; 92 } 93 94 /** 95 * External method return value 96 * 97 * @return external_value 98 */ 99 public static function execute_returns(): external_single_structure { 100 return custom_report_conditions_exporter::get_read_structure(); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body