Пример #1
0
 /**
  * Converts from current format to backup::MOODLE format
  */
 public function convert()
 {
     global $CFG;
     require_once $CFG->dirroot . '/backup/util/helper/convert_helper.class.php';
     // Basic/initial prevention against time/memory limits
     set_time_limit(1 * 60 * 60);
     // 1 hour for 1 course initially granted
     raise_memory_limit(MEMORY_EXTRA);
     if ($this->status != backup::STATUS_REQUIRE_CONV) {
         throw new restore_controller_exception('cannot_convert_not_required_status');
     }
     $this->log('backup format conversion required', backup::LOG_INFO);
     // Run conversion to the proper format
     if (!convert_helper::to_moodle2_format($this->get_tempdir(), $this->format, $this->get_logger())) {
         // todo - unable to find the conversion path, what to do now?
         // throwing the exception as a temporary solution
         throw new restore_controller_exception('unable_to_find_conversion_path');
     }
     $this->log('backup format conversion successful', backup::LOG_INFO);
     // If no exceptions were thrown, then we are in the proper format
     $this->format = backup::FORMAT_MOODLE;
     // Load plan, apply security and set status based on interactivity
     $this->load_plan();
     // Perform all initial security checks and apply (2nd param) them to settings automatically
     restore_check::check_security($this, true);
     if ($this->interactive == backup::INTERACTIVE_YES) {
         $this->set_status(backup::STATUS_SETTING_UI);
     } else {
         $this->set_status(backup::STATUS_NEED_PRECHECK);
     }
 }
<?php

define('CLI_SCRIPT', 1);
require_once '../../../config.php';
require_once $CFG->dirroot . '/backup/util/helper/convert_helper.class.php';
convert_helper::to_moodle2_format('refcourse', 'moodle1');