Merge branch 'MDL-28346-22' of git://github.com/FMCorz/moodle into MOODLE_22_STABLE

This commit is contained in:
Eloy Lafuente (stronk7) 2012-09-03 20:02:33 +02:00
commit 7b3a9020e6
13 changed files with 211 additions and 20 deletions

View file

@ -91,14 +91,19 @@ class file_nested_element extends backup_nested_element {
if (is_null($this->backupid)) { if (is_null($this->backupid)) {
$this->backupid = $processor->get_var(backup::VAR_BACKUPID); $this->backupid = $processor->get_var(backup::VAR_BACKUPID);
} }
parent::process($processor); return parent::process($processor);
} }
public function fill_values($values) { public function fill_values($values) {
// Fill values // Fill values
parent::fill_values($values); parent::fill_values($values);
// Do our own tasks (copy file from moodle to backup) // Do our own tasks (copy file from moodle to backup)
try {
backup_file_manager::copy_file_moodle2backup($this->backupid, $values); backup_file_manager::copy_file_moodle2backup($this->backupid, $values);
} catch (file_exception $e) {
$this->add_result(array('missing_files_in_pool' => true));
$this->add_log('missing file in pool: ' . $e->debuginfo, backup::LOG_WARNING);
}
} }
} }

View file

@ -622,10 +622,24 @@ abstract class restore_dbops {
* Given one component/filearea/context and * Given one component/filearea/context and
* optionally one source itemname to match itemids * optionally one source itemname to match itemids
* put the corresponding files in the pool * put the corresponding files in the pool
*
* @param string $basepath the full path to the root of unzipped backup file
* @param string $restoreid the restore job's identification
* @param string $component
* @param string $filearea
* @param int $oldcontextid
* @param int $dfltuserid default $file->user if the old one can't be mapped
* @param string|null $itemname
* @param int|null $olditemid
* @param int|null $forcenewcontextid explicit value for the new contextid (skip mapping)
* @param bool $skipparentitemidctxmatch
* @return array of result object
*/ */
public static function send_files_to_pool($basepath, $restoreid, $component, $filearea, $oldcontextid, $dfltuserid, $itemname = null, $olditemid = null, $forcenewcontextid = null, $skipparentitemidctxmatch = false) { public static function send_files_to_pool($basepath, $restoreid, $component, $filearea, $oldcontextid, $dfltuserid, $itemname = null, $olditemid = null, $forcenewcontextid = null, $skipparentitemidctxmatch = false) {
global $DB; global $DB;
$results = array();
if ($forcenewcontextid) { if ($forcenewcontextid) {
// Some components can have "forced" new contexts (example: questions can end belonging to non-standard context mappings, // Some components can have "forced" new contexts (example: questions can end belonging to non-standard context mappings,
// with questions originally at system/coursecat context in source being restored to course context in target). So we need // with questions originally at system/coursecat context in source being restored to course context in target). So we need
@ -701,7 +715,12 @@ abstract class restore_dbops {
// Find file in backup pool // Find file in backup pool
$backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash); $backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash);
if (!file_exists($backuppath)) { if (!file_exists($backuppath)) {
throw new restore_dbops_exception('file_not_found_in_pool', $file); $result = new stdClass();
$result->code = 'file_missing_in_backup';
$result->message = sprintf('missing file %s%s in backup', $file->filepath, $file->filename);
$result->level = backup::LOG_WARNING;
$results[] = $result;
continue;
} }
if (!$fs->file_exists($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->filename)) { if (!$fs->file_exists($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->filename)) {
$file_record = array( $file_record = array(
@ -721,6 +740,7 @@ abstract class restore_dbops {
} }
} }
$rs->close(); $rs->close();
return $results;
} }
/** /**

View file

@ -46,6 +46,8 @@ abstract class backup_cron_automated_helper {
const BACKUP_STATUS_UNFINISHED = 2; const BACKUP_STATUS_UNFINISHED = 2;
/** Course automated backup was skipped */ /** Course automated backup was skipped */
const BACKUP_STATUS_SKIPPED = 3; const BACKUP_STATUS_SKIPPED = 3;
/** Course automated backup had warnings */
const BACKUP_STATUS_WARNING = 4;
/** Run if required by the schedule set in config. Default. **/ /** Run if required by the schedule set in config. Default. **/
const RUN_ON_SCHEDULE = 0; const RUN_ON_SCHEDULE = 0;
@ -139,7 +141,7 @@ abstract class backup_cron_automated_helper {
$params = array('courseid' => $course->id, 'time' => $now-31*24*60*60, 'action' => '%view%'); $params = array('courseid' => $course->id, 'time' => $now-31*24*60*60, 'action' => '%view%');
$logexists = $DB->record_exists_select('log', $sqlwhere, $params); $logexists = $DB->record_exists_select('log', $sqlwhere, $params);
if (!$logexists) { if (!$logexists) {
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_SKIPPED; $backupcourse->laststatus = self::BACKUP_STATUS_SKIPPED;
$backupcourse->nextstarttime = $nextstarttime; $backupcourse->nextstarttime = $nextstarttime;
$DB->update_record('backup_courses', $backupcourse); $DB->update_record('backup_courses', $backupcourse);
mtrace('Skipping unchanged course '.$course->fullname); mtrace('Skipping unchanged course '.$course->fullname);
@ -160,7 +162,7 @@ abstract class backup_cron_automated_helper {
$starttime = time(); $starttime = time();
$backupcourse->laststarttime = time(); $backupcourse->laststarttime = time();
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED; $backupcourse->laststatus = self::BACKUP_STATUS_UNFINISHED;
$DB->update_record('backup_courses', $backupcourse); $DB->update_record('backup_courses', $backupcourse);
$backupcourse->laststatus = backup_cron_automated_helper::launch_automated_backup($course, $backupcourse->laststarttime, $admin->id); $backupcourse->laststatus = backup_cron_automated_helper::launch_automated_backup($course, $backupcourse->laststarttime, $admin->id);
@ -169,7 +171,7 @@ abstract class backup_cron_automated_helper {
$DB->update_record('backup_courses', $backupcourse); $DB->update_record('backup_courses', $backupcourse);
if ($backupcourse->laststatus) { if ($backupcourse->laststatus === self::BACKUP_STATUS_OK) {
// Clean up any excess course backups now that we have // Clean up any excess course backups now that we have
// taken a successful backup. // taken a successful backup.
$removedcount = backup_cron_automated_helper::remove_excess_backups($course); $removedcount = backup_cron_automated_helper::remove_excess_backups($course);
@ -188,17 +190,18 @@ abstract class backup_cron_automated_helper {
$message = ""; $message = "";
$count = backup_cron_automated_helper::get_backup_status_array(); $count = backup_cron_automated_helper::get_backup_status_array();
$haserrors = ($count[backup_cron_automated_helper::BACKUP_STATUS_ERROR] != 0 || $count[backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED] != 0); $haserrors = ($count[self::BACKUP_STATUS_ERROR] != 0 || $count[self::BACKUP_STATUS_UNFINISHED] != 0);
//Build the message text //Build the message text
//Summary //Summary
$message .= get_string('summary')."\n"; $message .= get_string('summary')."\n";
$message .= "==================================================\n"; $message .= "==================================================\n";
$message .= " ".get_string('courses').": ".array_sum($count)."\n"; $message .= " ".get_string('courses').": ".array_sum($count)."\n";
$message .= " ".get_string('ok').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_OK]."\n"; $message .= " ".get_string('ok').": ".$count[self::BACKUP_STATUS_OK]."\n";
$message .= " ".get_string('skipped').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_SKIPPED]."\n"; $message .= " ".get_string('skipped').": ".$count[self::BACKUP_STATUS_SKIPPED]."\n";
$message .= " ".get_string('error').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_ERROR]."\n"; $message .= " ".get_string('error').": ".$count[self::BACKUP_STATUS_ERROR]."\n";
$message .= " ".get_string('unfinished').": ".$count[backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED]."\n\n"; $message .= " ".get_string('unfinished').": ".$count[self::BACKUP_STATUS_UNFINISHED]."\n";
$message .= " ".get_string('warning').": ".$count[self::BACKUP_STATUS_WARNING]."\n\n";
//Reference //Reference
if ($haserrors) { if ($haserrors) {
@ -261,6 +264,7 @@ abstract class backup_cron_automated_helper {
self::BACKUP_STATUS_OK => 0, self::BACKUP_STATUS_OK => 0,
self::BACKUP_STATUS_UNFINISHED => 0, self::BACKUP_STATUS_UNFINISHED => 0,
self::BACKUP_STATUS_SKIPPED => 0, self::BACKUP_STATUS_SKIPPED => 0,
self::BACKUP_STATUS_WARNING => 0
); );
$statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus'); $statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');
@ -334,7 +338,7 @@ abstract class backup_cron_automated_helper {
*/ */
public static function launch_automated_backup($course, $starttime, $userid) { public static function launch_automated_backup($course, $starttime, $userid) {
$outcome = true; $outcome = self::BACKUP_STATUS_OK;
$config = get_config('backup'); $config = get_config('backup');
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_AUTOMATED, $userid); $bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_AUTOMATED, $userid);
@ -369,6 +373,7 @@ abstract class backup_cron_automated_helper {
$bc->execute_plan(); $bc->execute_plan();
$results = $bc->get_results(); $results = $bc->get_results();
$outcome = self::outcome_from_results($results);
$file = $results['backup_destination']; // may be empty if file already moved to target location $file = $results['backup_destination']; // may be empty if file already moved to target location
$dir = $config->backup_auto_destination; $dir = $config->backup_auto_destination;
$storage = (int)$config->backup_auto_storage; $storage = (int)$config->backup_auto_storage;
@ -377,8 +382,10 @@ abstract class backup_cron_automated_helper {
} }
if ($file && !empty($dir) && $storage !== 0) { if ($file && !empty($dir) && $storage !== 0) {
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, !$config->backup_shortname); $filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, !$config->backup_shortname);
$outcome = $file->copy_content_to($dir.'/'.$filename); if (!$file->copy_content_to($dir.'/'.$filename)) {
if ($outcome && $storage === 1) { $outcome = self::BACKUP_STATUS_ERROR;
}
if ($outcome != self::BACKUP_STATUS_ERROR && $storage === 1) {
$file->delete(); $file->delete();
} }
} }
@ -387,7 +394,7 @@ abstract class backup_cron_automated_helper {
$bc->log('backup_auto_failed_on_course', backup::LOG_ERROR, $course->shortname); // Log error header. $bc->log('backup_auto_failed_on_course', backup::LOG_ERROR, $course->shortname); // Log error header.
$bc->log('Exception: ' . $e->errorcode, backup::LOG_ERROR, $e->a, 1); // Log original exception problem. $bc->log('Exception: ' . $e->errorcode, backup::LOG_ERROR, $e->a, 1); // Log original exception problem.
$bc->log('Debug: ' . $e->debuginfo, backup::LOG_DEBUG, null, 1); // Log original debug information. $bc->log('Debug: ' . $e->debuginfo, backup::LOG_DEBUG, null, 1); // Log original debug information.
$outcome = false; $outcome = self::BACKUP_STATUS_ERROR;
} }
$bc->destroy(); $bc->destroy();
@ -396,6 +403,30 @@ abstract class backup_cron_automated_helper {
return $outcome; return $outcome;
} }
/**
* Returns the backup outcome by analysing its results.
*
* @param array $results returned by a backup
* @return int {@link self::BACKUP_STATUS_OK} and other constants
*/
public static function outcome_from_results($results) {
$outcome = self::BACKUP_STATUS_OK;
foreach ($results as $code => $value) {
// Each possible error and warning code has to be specified in this switch
// which basically analyses the results to return the correct backup status.
switch ($code) {
case 'missing_files_in_pool':
$outcome = self::BACKUP_STATUS_WARNING;
break;
}
// If we found the highest error level, we exit the loop.
if ($outcome == self::BACKUP_STATUS_ERROR) {
break;
}
}
return $outcome;
}
/** /**
* Removes deleted courses fromn the backup_courses table so that we don't * Removes deleted courses fromn the backup_courses table so that we don't
* waste time backing them up. * waste time backing them up.

View file

@ -94,11 +94,22 @@ abstract class backup_structure_step extends backup_step {
// Process structure definition // Process structure definition
$structure->process($pr); $structure->process($pr);
// Get the results from the nested elements
$results = $structure->get_results();
// Get the log messages to append to the log
$logs = $structure->get_logs();
foreach ($logs as $log) {
$this->log($log->message, $log->level, $log->a, $log->depth, $log->display);
}
// Close everything // Close everything
$xw->stop(); $xw->stop();
// Destroy the structure. It helps PHP 5.2 memory a lot! // Destroy the structure. It helps PHP 5.2 memory a lot!
$structure->destroy(); $structure->destroy();
return $results;
} }
/** /**

View file

@ -191,6 +191,34 @@ abstract class base_task implements checksumable, executable, loggable {
backup_general_helper::array_checksum_recursive($this->steps)); backup_general_helper::array_checksum_recursive($this->steps));
} }
/**
* Add the given info to the current plan's results.
*
* @see base_plan::add_result()
* @param array $result associative array describing a result of a task/step
*/
public function add_result($result) {
if (!is_null($this->plan)) {
$this->plan->add_result($result);
} else {
debugging('Attempting to add a result of a task not binded with a plan', DEBUG_DEVELOPER);
}
}
/**
* Return the current plan's results
*
* @return array|null
*/
public function get_results() {
if (!is_null($this->plan)) {
return $this->plan->get_results();
} else {
debugging('Attempting to get results of a task not binded with a plan', DEBUG_DEVELOPER);
return null;
}
}
// Protected API starts here // Protected API starts here
/** /**

View file

@ -218,8 +218,14 @@ abstract class restore_structure_step extends restore_step {
*/ */
public function add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null) { public function add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null) {
$filesctxid = is_null($filesctxid) ? $this->task->get_old_contextid() : $filesctxid; $filesctxid = is_null($filesctxid) ? $this->task->get_old_contextid() : $filesctxid;
restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $results = restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component,
$filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid); $filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid);
$resultstoadd = array();
foreach ($results as $result) {
$this->log($result->message, $result->level);
$resultstoadd[$result->code] = true;
}
$this->task->add_result($resultstoadd);
} }
/** /**

View file

@ -37,6 +37,8 @@ class backup_nested_element extends base_nested_element implements processable {
protected $aliases; // Define DB->final element aliases protected $aliases; // Define DB->final element aliases
protected $fileannotations; // array of file areas to be searched by file annotations protected $fileannotations; // array of file areas to be searched by file annotations
protected $counter; // Number of instances of this element that have been processed protected $counter; // Number of instances of this element that have been processed
protected $results; // Logs the results we encounter during the process.
protected $logs; // Some log messages that could be retrieved later.
/** /**
* Constructor - instantiates one backup_nested_element, specifying its basic info. * Constructor - instantiates one backup_nested_element, specifying its basic info.
@ -55,8 +57,16 @@ class backup_nested_element extends base_nested_element implements processable {
$this->aliases = array(); $this->aliases = array();
$this->fileannotations = array(); $this->fileannotations = array();
$this->counter = 0; $this->counter = 0;
$this->results = array();
$this->logs = array();
} }
/**
* Process the nested element
*
* @param object $processor the processor
* @return void
*/
public function process($processor) { public function process($processor) {
if (!$processor instanceof base_processor) { // No correct processor, throw exception if (!$processor instanceof base_processor) { // No correct processor, throw exception
throw new base_element_struct_exception('incorrect_processor'); throw new base_element_struct_exception('incorrect_processor');
@ -113,6 +123,69 @@ class backup_nested_element extends base_nested_element implements processable {
$iterator->close(); $iterator->close();
} }
/**
* Saves a log message to an array
*
* @see backup_helper::log()
* @param string $message to add to the logs
* @param int $level level of importance {@link backup::LOG_DEBUG} and other constants
* @param mixed $a to be included in $message
* @param int $depth of the message
* @param display $bool supporting translation via get_string() if true
* @return void
*/
protected function add_log($message, $level, $a = null, $depth = null, $display = false) {
// Adding the result to the oldest parent.
if ($this->get_parent()) {
$parent = $this->get_grandparent();
$parent->add_log($message, $level, $a, $depth, $display);
} else {
$log = new stdClass();
$log->message = $message;
$log->level = $level;
$log->a = $a;
$log->depth = $depth;
$log->display = $display;
$this->logs[] = $log;
}
}
/**
* Saves the results to an array
*
* @param array $result associative array
* @return void
*/
protected function add_result($result) {
if (is_array($result)) {
// Adding the result to the oldest parent.
if ($this->get_parent()) {
$parent = $this->get_grandparent();
$parent->add_result($result);
} else {
$this->results = array_merge($this->results, $result);
}
}
}
/**
* Returns the logs
*
* @return array of log objects
*/
public function get_logs() {
return $this->logs;
}
/**
* Returns the results
*
* @return associative array of results
*/
public function get_results() {
return $this->results;
}
public function set_source_array($arr) { public function set_source_array($arr) {
// TODO: Only elements having final elements can set source // TODO: Only elements having final elements can set source
$this->var_array = $arr; $this->var_array = $arr;

View file

@ -469,6 +469,9 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
} }
echo $OUTPUT->box_start(); echo $OUTPUT->box_start();
if (!empty($this->results['missing_files_in_pool'])) {
echo $OUTPUT->notification(get_string('missingfilesinpool', 'backup'), 'notifyproblem');
}
echo $OUTPUT->notification(get_string('executionsuccess', 'backup'), 'notifysuccess'); echo $OUTPUT->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
echo $OUTPUT->continue_button($restorerul); echo $OUTPUT->continue_button($restorerul);
echo $OUTPUT->box_end(); echo $OUTPUT->box_end();

View file

@ -757,6 +757,9 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
$html = ''; $html = '';
$html .= $renderer->box_start(); $html .= $renderer->box_start();
if (array_key_exists('file_missing_in_backup', $this->results)) {
$html .= $renderer->notification(get_string('restorefileweremissing', 'backup'), 'notifyproblem');
}
$html .= $renderer->notification(get_string('restoreexecutionsuccess', 'backup'), 'notifysuccess'); $html .= $renderer->notification(get_string('restoreexecutionsuccess', 'backup'), 'notifysuccess');
$html .= $renderer->continue_button(new moodle_url('/course/view.php', array( $html .= $renderer->continue_button(new moodle_url('/course/view.php', array(
'id' => $this->get_ui()->get_controller()->get_courseid())), 'get'); 'id' => $this->get_ui()->get_controller()->get_courseid())), 'get');

View file

@ -153,6 +153,7 @@ $string['lockedbypermission'] = 'You don\'t have sufficient permissions to chang
$string['lockedbyconfig'] = 'This setting has been locked by the default backup settings'; $string['lockedbyconfig'] = 'This setting has been locked by the default backup settings';
$string['lockedbyhierarchy'] = 'Locked by dependencies'; $string['lockedbyhierarchy'] = 'Locked by dependencies';
$string['managefiles'] = 'Manage backup files'; $string['managefiles'] = 'Manage backup files';
$string['missingfilesinpool'] = 'Some files could not be saved during the backup, it won\'t be possible to restore them.';
$string['moodleversion'] = 'Moodle version'; $string['moodleversion'] = 'Moodle version';
$string['moreresults'] = 'There are too many results, enter a more specific search.'; $string['moreresults'] = 'There are too many results, enter a more specific search.';
$string['nomatchingcourses'] = 'There are no courses to display'; $string['nomatchingcourses'] = 'There are no courses to display';
@ -167,6 +168,7 @@ $string['restoreactivity'] = 'Restore activity';
$string['restorecourse'] = 'Restore course'; $string['restorecourse'] = 'Restore course';
$string['restorecoursesettings'] = 'Course settings'; $string['restorecoursesettings'] = 'Course settings';
$string['restoreexecutionsuccess'] = 'The course was restored successfully, clicking the continue button below will take you to view the course you restored.'; $string['restoreexecutionsuccess'] = 'The course was restored successfully, clicking the continue button below will take you to view the course you restored.';
$string['restorefileweremissing'] = 'Some files could not be restored because they were missing in the backup.';
$string['restorenewcoursefullname'] = 'New course name'; $string['restorenewcoursefullname'] = 'New course name';
$string['restorenewcourseshortname'] = 'New course short name'; $string['restorenewcourseshortname'] = 'New course short name';
$string['restorenewcoursestartdate'] = 'New start date'; $string['restorenewcoursestartdate'] = 'New start date';

View file

@ -1764,6 +1764,7 @@ $string['virusfounduser'] = 'The file you have uploaded, {$a->filename}, has bee
$string['virusplaceholder'] = 'This file that has been uploaded was found to contain a virus and has been moved or deleted and the user notified.'; $string['virusplaceholder'] = 'This file that has been uploaded was found to contain a virus and has been moved or deleted and the user notified.';
$string['visible'] = 'Visible'; $string['visible'] = 'Visible';
$string['visibletostudents'] = 'Visible to {$a}'; $string['visibletostudents'] = 'Visible to {$a}';
$string['warning'] = 'Warning';
$string['warningdeleteresource'] = 'Warning: {$a} is referred in a resource. Would you like to update the resource?'; $string['warningdeleteresource'] = 'Warning: {$a} is referred in a resource. Would you like to update the resource?';
$string['webpage'] = 'Web page'; $string['webpage'] = 'Web page';
$string['week'] = 'Week'; $string['week'] = 'Week';

View file

@ -27,6 +27,9 @@ require_once('../../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/backup/lib.php'); require_once($CFG->dirroot.'/backup/lib.php');
// Required for constants in backup_cron_automated_helper
require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php');
admin_externalpage_setup('reportbackups', '', null, '', array('pagelayout'=>'report')); admin_externalpage_setup('reportbackups', '', null, '', array('pagelayout'=>'report'));
$table = new html_table; $table = new html_table;
@ -45,6 +48,7 @@ $strerror = get_string("error");
$strok = get_string("ok"); $strok = get_string("ok");
$strunfinished = get_string("unfinished"); $strunfinished = get_string("unfinished");
$strskipped = get_string("skipped"); $strskipped = get_string("skipped");
$strwarning = get_string("warning");
list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT bc.*, c.fullname $select $sql = "SELECT bc.*, c.fullname $select
@ -58,15 +62,18 @@ foreach ($rs as $backuprow) {
context_instance_preload($backuprow); context_instance_preload($backuprow);
// Prepare a cell to display the status of the entry // Prepare a cell to display the status of the entry
if ($backuprow->laststatus == 1) { if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_OK) {
$status = $strok; $status = $strok;
$statusclass = 'backup-ok'; // Green $statusclass = 'backup-ok'; // Green
} else if ($backuprow->laststatus == 2) { } else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED) {
$status = $strunfinished; $status = $strunfinished;
$statusclass = 'backup-unfinished'; // Red $statusclass = 'backup-unfinished'; // Red
} else if ($backuprow->laststatus == 3) { } else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_SKIPPED) {
$status = $strskipped; $status = $strskipped;
$statusclass = 'backup-skipped'; // Green $statusclass = 'backup-skipped'; // Green
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_WARNING) {
$status = $strwarning;
$statusclass = 'backup-warning'; // Orange
} else { } else {
$status = $strerror; $status = $strerror;
$statusclass = 'backup-error'; // Red $statusclass = 'backup-error'; // Red

View file

@ -42,6 +42,7 @@
#page-admin-report-backups-index .backup-unfinished {color: #f00000;} #page-admin-report-backups-index .backup-unfinished {color: #f00000;}
#page-admin-report-backups-index .backup-skipped, #page-admin-report-backups-index .backup-skipped,
#page-admin-report-backups-index .backup-ok {color: #006400;} #page-admin-report-backups-index .backup-ok {color: #006400;}
#page-admin-report-backups-index .backup-warning {color: #ff9900;}
#page-admin-qbehaviours .disabled {color: gray;} #page-admin-qbehaviours .disabled {color: gray;}
#page-admin-qbehaviours th {white-space: normal;} #page-admin-qbehaviours th {white-space: normal;}