mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-38196-master' of git://github.com/sammarshallou/moodle
Conflicts: backup/backup.php theme/bootstrapbase/style/moodle.css
This commit is contained in:
commit
f0ae8d7a66
@ -116,12 +116,24 @@ if ($backup->enforce_changed_dependencies()) {
|
||||
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
$loghtml = '';
|
||||
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
// Display an extra progress bar so that we can show the progress first.
|
||||
// Display an extra backup step bar so that we can show the 'processing' step first.
|
||||
echo html_writer::start_div('', array('id' => 'executionprogress'));
|
||||
echo $renderer->progress_bar($backup->get_progress_bar());
|
||||
$backup->get_controller()->set_progress(new core_backup_display_progress());
|
||||
|
||||
// Prepare logger and add to end of chain.
|
||||
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
|
||||
$backup->get_controller()->add_logger($logger);
|
||||
|
||||
// Carry out actual backup.
|
||||
$backup->execute();
|
||||
|
||||
// Get HTML from logger.
|
||||
$loghtml = $logger->get_html();
|
||||
|
||||
// Hide the progress display and first backup step bar (the 'finished' step will show next).
|
||||
echo html_writer::end_div();
|
||||
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
|
||||
} else {
|
||||
@ -140,4 +152,10 @@ echo $renderer->progress_bar($backup->get_progress_bar());
|
||||
echo $ui;
|
||||
$backup->destroy();
|
||||
unset($backup);
|
||||
|
||||
// Display log data if there was any.
|
||||
if ($loghtml != '') {
|
||||
echo $renderer->log_display($loghtml);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -40,7 +40,7 @@
|
||||
*
|
||||
* TODO: Finish phpdocs
|
||||
*/
|
||||
class backup_controller extends backup implements loggable {
|
||||
class backup_controller extends base_controller {
|
||||
|
||||
protected $backupid; // Unique identificator for this backup
|
||||
|
||||
@ -62,12 +62,6 @@ class backup_controller extends backup implements loggable {
|
||||
protected $executiontime; // epoch time when we want the backup to be executed (requires cron to run)
|
||||
|
||||
protected $destination; // Destination chain object (fs_moodle, fs_os, db, email...)
|
||||
protected $logger; // Logging chain object (moodle, inline, fs, db, syslog)
|
||||
|
||||
/**
|
||||
* @var core_backup_progress Progress reporting object.
|
||||
*/
|
||||
protected $progress;
|
||||
|
||||
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
|
||||
|
||||
@ -307,29 +301,6 @@ class backup_controller extends backup implements loggable {
|
||||
return $this->plan;
|
||||
}
|
||||
|
||||
public function get_logger() {
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress reporter, which can be used to report progress within
|
||||
* the backup or restore process.
|
||||
*
|
||||
* @return core_backup_progress Progress reporting object
|
||||
*/
|
||||
public function get_progress() {
|
||||
return $this->progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress reporter.
|
||||
*
|
||||
* @param core_backup_progress $progress Progress reporting object
|
||||
*/
|
||||
public function set_progress(core_backup_progress $progress) {
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the backup
|
||||
* @return void Throws and exception of completes
|
||||
@ -353,10 +324,6 @@ class backup_controller extends backup implements loggable {
|
||||
return $this->plan->get_results();
|
||||
}
|
||||
|
||||
public function log($message, $level, $a = null, $depth = null, $display = false) {
|
||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save controller information
|
||||
*
|
||||
|
85
backup/controller/base_controller.class.php
Normal file
85
backup/controller/base_controller.class.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Base class with shared stuff between backup controller and restore
|
||||
* controller.
|
||||
*
|
||||
* @package core_backup
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class base_controller extends backup implements loggable {
|
||||
/**
|
||||
* @var core_backup_progress Progress reporting object.
|
||||
*/
|
||||
protected $progress;
|
||||
|
||||
/**
|
||||
* @var base_logger Logging chain object (moodle, inline, fs, db, syslog)
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Gets the progress reporter, which can be used to report progress within
|
||||
* the backup or restore process.
|
||||
*
|
||||
* @return core_backup_progress Progress reporting object
|
||||
*/
|
||||
public function get_progress() {
|
||||
return $this->progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress reporter.
|
||||
*
|
||||
* @param core_backup_progress $progress Progress reporting object
|
||||
*/
|
||||
public function set_progress(core_backup_progress $progress) {
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets first logger in logging chain.
|
||||
*
|
||||
* @return base_logger Logger
|
||||
*/
|
||||
public function get_logger() {
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new logger at end of logging chain.
|
||||
*
|
||||
* @param base_logger $logger New logger to add
|
||||
*/
|
||||
public function add_logger(base_logger $logger) {
|
||||
$existing = $this->logger;
|
||||
while ($existing->get_next()) {
|
||||
$existing = $existing->get_next();
|
||||
}
|
||||
$existing->set_next($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs data to the logger chain.
|
||||
*
|
||||
* @see loggable::log()
|
||||
*/
|
||||
public function log($message, $level, $a = null, $depth = null, $display = false) {
|
||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* TODO: Finish phpdocs
|
||||
*/
|
||||
class restore_controller extends backup implements loggable {
|
||||
class restore_controller extends base_controller {
|
||||
|
||||
protected $tempdir; // Directory under tempdir/backup awaiting restore
|
||||
protected $restoreid; // Unique identificator for this restore
|
||||
@ -55,13 +55,6 @@ class restore_controller extends backup implements loggable {
|
||||
protected $execution; // inmediate/delayed
|
||||
protected $executiontime; // epoch time when we want the restore to be executed (requires cron to run)
|
||||
|
||||
protected $logger; // Logging chain object (moodle, inline, fs, db, syslog)
|
||||
|
||||
/**
|
||||
* @var core_backup_progress Progress reporting object.
|
||||
*/
|
||||
protected $progress;
|
||||
|
||||
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
|
||||
|
||||
/**
|
||||
@ -305,29 +298,6 @@ class restore_controller extends backup implements loggable {
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function get_logger() {
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress reporter, which can be used to report progress within
|
||||
* the backup or restore process.
|
||||
*
|
||||
* @return core_backup_progress Progress reporting object
|
||||
*/
|
||||
public function get_progress() {
|
||||
return $this->progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress reporter.
|
||||
*
|
||||
* @param core_backup_progress $progress Progress reporting object
|
||||
*/
|
||||
public function set_progress(core_backup_progress $progress) {
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
public function execute_plan() {
|
||||
// Basic/initial prevention against time/memory limits
|
||||
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||
@ -395,10 +365,6 @@ class restore_controller extends backup implements loggable {
|
||||
return $this->precheck;
|
||||
}
|
||||
|
||||
public function log($message, $level, $a = null, $depth = null, $display = false) {
|
||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save controller information
|
||||
*
|
||||
|
@ -99,6 +99,10 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
$progress->start_progress('', 2);
|
||||
$backup->get_controller()->set_progress($progress);
|
||||
|
||||
// Prepare logger for backup.
|
||||
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
|
||||
$backup->get_controller()->add_logger($logger);
|
||||
|
||||
// First execute the backup
|
||||
$backup->execute();
|
||||
$backup->destroy();
|
||||
@ -123,6 +127,10 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
// (the precheck and then the actual restore).
|
||||
$progress->start_progress('Restore process', 2);
|
||||
$rc->set_progress($progress);
|
||||
|
||||
// Set logger for restore.
|
||||
$rc->add_logger($logger);
|
||||
|
||||
// Convert the backup if required.... it should NEVER happed
|
||||
if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
|
||||
$rc->convert();
|
||||
@ -178,6 +186,13 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
}
|
||||
echo $OUTPUT->notification(get_string('importsuccess', 'backup'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
|
||||
// Get and display log data if there was any.
|
||||
$loghtml = $logger->get_html();
|
||||
if ($loghtml != '') {
|
||||
echo $renderer->log_display($loghtml);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
die();
|
||||
|
@ -3625,7 +3625,7 @@ class restore_process_file_aliases_queue extends restore_execution_step {
|
||||
protected function define_execution() {
|
||||
global $DB;
|
||||
|
||||
$this->log('processing file aliases queue', backup::LOG_INFO);
|
||||
$this->log('processing file aliases queue', backup::LOG_DEBUG);
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
||||
|
@ -61,6 +61,7 @@ if (!$restore->is_independent() && $restore->enforce_changed_dependencies()) {
|
||||
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
$loghtml = '';
|
||||
if (!$restore->is_independent()) {
|
||||
// Use a temporary (disappearing) progress bar to show the precheck progress if any.
|
||||
$precheckprogress = new core_backup_display_progress_if_slow(get_string('preparingdata', 'backup'));
|
||||
@ -72,9 +73,14 @@ if (!$restore->is_independent()) {
|
||||
// Show the current restore state (header with bolded item).
|
||||
echo $renderer->progress_bar($restore->get_progress_bar());
|
||||
// Start displaying the actual progress bar percentage.
|
||||
$restore->get_controller()->set_progress(new core_backup_display_progress(true));
|
||||
$restore->get_controller()->set_progress(new core_backup_display_progress());
|
||||
// Prepare logger.
|
||||
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
|
||||
$restore->get_controller()->add_logger($logger);
|
||||
// Do actual restore.
|
||||
$restore->execute();
|
||||
// Get HTML from logger.
|
||||
$loghtml = $logger->get_html();
|
||||
// Hide this section because we are now going to make the page show 'finished'.
|
||||
echo html_writer::end_div();
|
||||
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
|
||||
@ -91,4 +97,10 @@ echo $renderer->progress_bar($restore->get_progress_bar());
|
||||
echo $restore->display($renderer);
|
||||
$restore->destroy();
|
||||
unset($restore);
|
||||
|
||||
// Display log data if there was any.
|
||||
if ($loghtml != '') {
|
||||
echo $renderer->log_display($loghtml);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -69,6 +69,7 @@ require_once($CFG->dirroot . '/backup/util/xml/parser/progressive_parser.class.p
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
|
||||
@ -90,6 +91,7 @@ require_once($CFG->dirroot . '/backup/util/plan/base_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/plan/backup_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/plan/backup_structure_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/plan/backup_execution_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');
|
||||
require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
|
||||
|
@ -58,6 +58,7 @@ require_once($CFG->dirroot . '/backup/util/checks/restore_check.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
|
||||
@ -84,6 +85,7 @@ require_once($CFG->dirroot . '/backup/util/plan/restore_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/plan/restore_structure_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/plan/restore_execution_step.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_plan_builder.class.php');
|
||||
require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');
|
||||
require_once($CFG->dirroot . '/backup/controller/restore_controller.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');
|
||||
require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');
|
||||
|
46
backup/util/loggers/core_backup_html_logger.class.php
Normal file
46
backup/util/loggers/core_backup_html_logger.class.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Logger that stores HTML log data in memory, ready for later display.
|
||||
*
|
||||
* @package core_backup
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_backup_html_logger extends base_logger {
|
||||
/**
|
||||
* @var string HTML output
|
||||
*/
|
||||
protected $html = '';
|
||||
|
||||
protected function action($message, $level, $options = null) {
|
||||
$prefix = $this->get_prefix($level, $options);
|
||||
$depth = isset($options['depth']) ? $options['depth'] : 0;
|
||||
$this->html .= $prefix . str_repeat(' ', $depth) .
|
||||
s($message) . '<br/>' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full HTML content of the log.
|
||||
*
|
||||
* @return string HTML content of log
|
||||
*/
|
||||
public function get_html() {
|
||||
return $this->html;
|
||||
}
|
||||
}
|
@ -55,6 +55,24 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||
}
|
||||
return html_writer::tag('div', join(get_separator(), $items), array('class'=>'backup_progress clearfix'));
|
||||
}
|
||||
|
||||
/**
|
||||
* The backup and restore pages may display a log (if any) in a scrolling box.
|
||||
*
|
||||
* @param string $loghtml Log content in HTML format
|
||||
* @return string HTML content that shows the log
|
||||
*/
|
||||
public function log_display($loghtml) {
|
||||
global $OUTPUT;
|
||||
$out = html_writer::start_div('backup_log');
|
||||
$out .= $OUTPUT->heading(get_string('backuplog', 'backup'));
|
||||
$out .= html_writer::start_div('backup_log_contents');
|
||||
$out .= $loghtml;
|
||||
$out .= html_writer::end_div();
|
||||
$out .= html_writer::end_div();
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a dependency notification
|
||||
* @param string $message
|
||||
|
@ -49,6 +49,7 @@ $string['backupformatmoodle2'] = 'Moodle 2';
|
||||
$string['backupformatimscc1'] = 'IMS Common Cartridge 1.0';
|
||||
$string['backupformatimscc11'] = 'IMS Common Cartridge 1.1';
|
||||
$string['backupformatunknown'] = 'Unknown format';
|
||||
$string['backuplog'] = 'Technical information and warnings';
|
||||
$string['backupmode'] = 'Mode';
|
||||
$string['backupmode10'] = 'General';
|
||||
$string['backupmode20'] = 'Import';
|
||||
|
@ -567,6 +567,9 @@ body.tag .managelink {padding: 5px;}
|
||||
.path-backup .wibbler .state10 { background: #444; }
|
||||
.path-backup .wibbler .state11 { background: #333; }
|
||||
.path-backup .wibbler .state12 { background: #222; }
|
||||
.path-backup .backup_log { margin-top: 2em; }
|
||||
.path-backup .backup_log h2 { font-size: 1em; }
|
||||
.path-backup .backup_log_contents { border: 1px solid #ddd; padding: 10px; height: 300px; overflow-y: scroll; }
|
||||
|
||||
/**
|
||||
* Web Service
|
||||
|
@ -217,3 +217,15 @@
|
||||
.path-backup .wibbler .state12 {
|
||||
background: #222;
|
||||
}
|
||||
.path-backup .backup_log {
|
||||
margin-top: 2em;
|
||||
}
|
||||
.path-backup .backup_log h2 {
|
||||
font-size: 1em;
|
||||
}
|
||||
.path-backup .backup_log_contents {
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
height: 300px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user