Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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  /**
  18   * Edit a custom report
  19   *
  20   * @package   core_reportbuilder
  21   * @copyright 2021 David Matamoros <davidmc@moodle.com>
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  declare(strict_types=1);
  26  
  27  use core\output\dynamic_tabs;
  28  use core_reportbuilder\manager;
  29  use core_reportbuilder\permission;
  30  use core_reportbuilder\output\dynamictabs\access;
  31  use core_reportbuilder\output\dynamictabs\audience;
  32  use core_reportbuilder\output\dynamictabs\editor;
  33  use core_reportbuilder\output\dynamictabs\schedules;
  34  
  35  require_once(__DIR__ . '/../config.php');
  36  require_once("{$CFG->libdir}/adminlib.php");
  37  
  38  $reportid = required_param('id', PARAM_INT);
  39  
  40  admin_externalpage_setup('customreports', null, ['id' => $reportid], new moodle_url('/reportbuilder/edit.php'));
  41  navigation_node::override_active_url(new moodle_url('/reportbuilder/index.php'));
  42  
  43  $report = manager::get_report_from_id($reportid);
  44  permission::require_can_edit_report($report->get_report_persistent());
  45  
  46  $PAGE->set_context($report->get_context());
  47  $PAGE->navbar->add(get_string('editreportcontent', 'core_reportbuilder'), $PAGE->url);
  48  $PAGE->set_pagelayout('popup');
  49  
  50  /** @var \core_reportbuilder\output\renderer $renderer */
  51  $renderer = $PAGE->get_renderer('core_reportbuilder');
  52  
  53  $reportname = $report->get_report_persistent()->get_formatted_name();
  54  $PAGE->set_title($reportname);
  55  
  56  echo $OUTPUT->header();
  57  
  58  echo $renderer->render_fullpage_editor_header($report->get_report_persistent());
  59  
  60  // Add dynamic tabs.
  61  $tabdata = ['reportid' => $reportid];
  62  $tabs = [
  63      new editor($tabdata),
  64      new audience($tabdata),
  65      new schedules($tabdata),
  66      new access($tabdata),
  67  ];
  68  
  69  echo $OUTPUT->render_from_template('core/dynamic_tabs',
  70      (new dynamic_tabs($tabs))->export_for_template($OUTPUT));
  71  
  72  echo $OUTPUT->footer();