Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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   * Import files from skydrive.
  19   *
  20   * @package    repository_onedrive
  21   * @copyright  2017 Damyon Wiese <damyon@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require_once(__DIR__ . '/../../config.php');
  26  
  27  $PAGE->set_url('/repository/onedrive/importskydrive.php');
  28  $PAGE->set_context(context_system::instance());
  29  $strheading = get_string('importskydrivefiles', 'repository_onedrive');
  30  $PAGE->set_title($strheading);
  31  $PAGE->set_heading($strheading);
  32  
  33  require_login();
  34  
  35  require_capability('moodle/site:config', context_system::instance());
  36  
  37  $confirm = optional_param('confirm', false, PARAM_BOOL);
  38  
  39  if ($confirm) {
  40      require_sesskey();
  41      require_once($CFG->dirroot . '/repository/lib.php');
  42      require_once($CFG->dirroot . '/repository/onedrive/lib.php');
  43  
  44      if (repository_onedrive::import_skydrive_files()) {
  45          $mesg = get_string('skydrivefilesimported', 'repository_onedrive');
  46          redirect(new moodle_url('/admin/repository.php'), $mesg, null, \core\output\notification::NOTIFY_SUCCESS);
  47      } else {
  48          $mesg = get_string('skydrivefilesnotimported', 'repository_onedrive');
  49          redirect(new moodle_url('/admin/repository.php'), $mesg, null, \core\output\notification::NOTIFY_ERROR);
  50      }
  51  } else {
  52      $continueurl = new moodle_url('/repository/onedrive/importskydrive.php', ['confirm' => true]);
  53      $cancelurl = new moodle_url('/admin/repository.php');
  54      echo $OUTPUT->header();
  55      echo $OUTPUT->confirm(get_string('confirmimportskydrive', 'repository_onedrive'), $continueurl, $cancelurl);
  56      echo $OUTPUT->footer();
  57  }