Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/portfolio/ -> file.php (source)

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 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  /**
  18   * For portfolio plugins that are 'pull' - ie, send the request and then wait
  19   * for the remote system to request the file for moodle,
  20   * this is the script that serves up the export file to them.
  21   *
  22   * @package core_portfolio
  23   * @copyright 2008 Penny Leach <penny@catalyst.net.nz>,
  24   *            Martin Dougiamas <http://dougiamas.com>
  25   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  require_once(__DIR__ . '/../config.php');
  28  
  29  if (empty($CFG->enableportfolios)) {
  30      print_error('disabled', 'portfolio');
  31  }
  32  
  33  require_once($CFG->libdir . '/portfoliolib.php');
  34  require_once($CFG->libdir . '/portfolio/exporter.php');
  35  require_once($CFG->libdir . '/filelib.php');
  36  
  37  // exporter id
  38  $id = required_param('id', PARAM_INT);
  39  
  40  require_login();
  41  $PAGE->set_url('/portfolio/add.php', array('id' => $id));
  42  
  43  $exporter = portfolio_exporter::rewaken_object($id);
  44  $exporter->verify_rewaken();
  45  
  46  // push plugins don't need to access this script.
  47  if ($exporter->get('instance')->is_push()) {
  48      throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
  49  }
  50  
  51  // it's up to the plugin to verify the request parameters, like a token or whatever
  52  if (!$exporter->get('instance')->verify_file_request_params(array_merge($_GET, $_POST))) {
  53      throw new portfolio_export_exception($exporter, 'filedenied', 'portfolio');
  54  }
  55  
  56  // ok, we're good, send the file and finish the export.
  57  $exporter->get('instance')->send_file();
  58  $exporter->process_stage_cleanup(true);
  59  exit;
  60