MDL-42201 backup: introduced new automatic backup state
This commit is contained in:
@@ -32,11 +32,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
abstract class backup_cron_automated_helper {
|
||||
|
||||
/** automated backups are active and ready to run */
|
||||
/** Automated backups are active and ready to run */
|
||||
const STATE_OK = 0;
|
||||
/** automated backups are disabled and will not be run */
|
||||
/** Automated backups are disabled and will not be run */
|
||||
const STATE_DISABLED = 1;
|
||||
/** automated backups are all ready running! */
|
||||
/** Automated backups are all ready running! */
|
||||
const STATE_RUNNING = 2;
|
||||
|
||||
/** Course automated backup completed successfully */
|
||||
@@ -49,6 +49,8 @@ abstract class backup_cron_automated_helper {
|
||||
const BACKUP_STATUS_SKIPPED = 3;
|
||||
/** Course automated backup had warnings */
|
||||
const BACKUP_STATUS_WARNING = 4;
|
||||
/** Course automated backup has yet to be run */
|
||||
const BACKUP_STATUS_NOTYETRUN = 5;
|
||||
|
||||
/** Run if required by the schedule set in config. Default. **/
|
||||
const RUN_ON_SCHEDULE = 0;
|
||||
@@ -120,12 +122,13 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$rs = $DB->get_recordset('course');
|
||||
foreach ($rs as $course) {
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid' => $course->id));
|
||||
if (!$backupcourse) {
|
||||
$backupcourse = new stdClass;
|
||||
$backupcourse->courseid = $course->id;
|
||||
$DB->insert_record('backup_courses',$backupcourse);
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
$backupcourse->laststatus = self::BACKUP_STATUS_NOTYETRUN;
|
||||
$DB->insert_record('backup_courses', $backupcourse);
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid' => $course->id));
|
||||
}
|
||||
|
||||
// The last backup is considered as successful when OK or SKIPPED.
|
||||
@@ -229,16 +232,17 @@ abstract class backup_cron_automated_helper {
|
||||
$count = backup_cron_automated_helper::get_backup_status_array();
|
||||
$haserrors = ($count[self::BACKUP_STATUS_ERROR] != 0 || $count[self::BACKUP_STATUS_UNFINISHED] != 0);
|
||||
|
||||
//Build the message text
|
||||
//Summary
|
||||
$message .= get_string('summary')."\n";
|
||||
// Build the message text.
|
||||
// Summary.
|
||||
$message .= get_string('summary') . "\n";
|
||||
$message .= "==================================================\n";
|
||||
$message .= " ".get_string('courses').": ".array_sum($count)."\n";
|
||||
$message .= " ".get_string('ok').": ".$count[self::BACKUP_STATUS_OK]."\n";
|
||||
$message .= " ".get_string('skipped').": ".$count[self::BACKUP_STATUS_SKIPPED]."\n";
|
||||
$message .= " ".get_string('error').": ".$count[self::BACKUP_STATUS_ERROR]."\n";
|
||||
$message .= " ".get_string('unfinished').": ".$count[self::BACKUP_STATUS_UNFINISHED]."\n";
|
||||
$message .= " ".get_string('warning').": ".$count[self::BACKUP_STATUS_WARNING]."\n\n";
|
||||
$message .= ' ' . get_string('courses') . '; ' . array_sum($count) . "\n";
|
||||
$message .= ' ' . get_string('ok') . '; ' . $count[self::BACKUP_STATUS_OK] . "\n";
|
||||
$message .= ' ' . get_string('skipped') . '; ' . $count[self::BACKUP_STATUS_SKIPPED] . "\n";
|
||||
$message .= ' ' . get_string('error') . '; ' . $count[self::BACKUP_STATUS_ERROR] . "\n";
|
||||
$message .= ' ' . get_string('unfinished') . '; ' . $count[self::BACKUP_STATUS_UNFINISHED] . "\n";
|
||||
$message .= ' ' . get_string('warning') . '; ' . $count[self::BACKUP_STATUS_WARNING] . "\n";
|
||||
$message .= ' ' . get_string('backupnotyetrun') . '; ' . $count[self::BACKUP_STATUS_NOTYETRUN]."\n\n";
|
||||
|
||||
//Reference
|
||||
if ($haserrors) {
|
||||
@@ -301,7 +305,8 @@ abstract class backup_cron_automated_helper {
|
||||
self::BACKUP_STATUS_OK => 0,
|
||||
self::BACKUP_STATUS_UNFINISHED => 0,
|
||||
self::BACKUP_STATUS_SKIPPED => 0,
|
||||
self::BACKUP_STATUS_WARNING => 0
|
||||
self::BACKUP_STATUS_WARNING => 0,
|
||||
self::BACKUP_STATUS_NOTYETRUN => 0
|
||||
);
|
||||
|
||||
$statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');
|
||||
|
||||
@@ -185,6 +185,7 @@ $string['backuploglaststatus'] = 'Last execution log';
|
||||
$string['backupmissinguserinfoperms'] = 'Note: This backup contains no user data. Exercise and Workshop activities will not be included in the backup, since these modules are not compatible with this type of backup.';
|
||||
$string['backupnext'] = 'Next backup';
|
||||
$string['backupnonisowarning'] = 'Warning: this backup is from a non-Unicode version of Moodle (pre 1.6). If this backup contains any non-ISO-8859-1 texts then they may be CORRUPTED if you try to restore them to this Unicode version of Moodle. See the <a href="http://docs.moodle.org/en/Backup_FAQ">Backup FAQ</a> for more information about how to recover this backup correctly.';
|
||||
$string['backupnotyetrun'] = 'Automated backup pending';
|
||||
$string['backuporiginalname'] = 'Backup name';
|
||||
$string['backuproleassignments'] = 'Backup role assignments for these roles';
|
||||
$string['backupsavetohelp'] = 'Full path to the directory where you want to save the backup files<br />(leave blank to save in its course default dir)';
|
||||
|
||||
+16
-12
@@ -42,12 +42,13 @@ $table->headspan = array(1, 3, 1, 1);
|
||||
$table->attributes = array('class' => 'generaltable backup-report');
|
||||
$table->data = array();
|
||||
|
||||
$strftimedatetime = get_string("strftimerecent");
|
||||
$strerror = get_string("error");
|
||||
$strok = get_string("ok");
|
||||
$strunfinished = get_string("unfinished");
|
||||
$strskipped = get_string("skipped");
|
||||
$strwarning = get_string("warning");
|
||||
$strftimedatetime = get_string('strftimerecent');
|
||||
$strerror = get_string('error');
|
||||
$strok = get_string('ok');
|
||||
$strunfinished = get_string('unfinished');
|
||||
$strskipped = get_string('skipped');
|
||||
$strwarning = get_string('warning');
|
||||
$strnotyetrun = get_string('backupnotyetrun');
|
||||
|
||||
list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT bc.*, c.fullname $select
|
||||
@@ -60,22 +61,25 @@ foreach ($rs as $backuprow) {
|
||||
// Cache the course context
|
||||
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 == backup_cron_automated_helper::BACKUP_STATUS_OK) {
|
||||
$status = $strok;
|
||||
$statusclass = 'backup-ok'; // Green
|
||||
$statusclass = 'backup-ok'; // Green.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_UNFINISHED) {
|
||||
$status = $strunfinished;
|
||||
$statusclass = 'backup-unfinished'; // Red
|
||||
$statusclass = 'backup-unfinished'; // Red.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_SKIPPED) {
|
||||
$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
|
||||
$statusclass = 'backup-warning'; // Orange.
|
||||
} else if ($backuprow->laststatus == backup_cron_automated_helper::BACKUP_STATUS_NOTYETRUN) {
|
||||
$status = $strnotyetrun;
|
||||
$statusclass = 'backup-notyetrun';
|
||||
} else {
|
||||
$status = $strerror;
|
||||
$statusclass = 'backup-error'; // Red
|
||||
$statusclass = 'backup-error'; // Red.
|
||||
}
|
||||
$status = new html_table_cell($status);
|
||||
$status->attributes = array('class' => $statusclass);
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
#page-admin-report-backups-index .backup-skipped,
|
||||
#page-admin-report-backups-index .backup-ok {color: #006400;}
|
||||
#page-admin-report-backups-index .backup-warning {color: #ff9900;}
|
||||
#page-admin-report-backups-index .backup-notyetrun {color: #006400;}
|
||||
|
||||
#page-admin-qbehaviours .disabled {color: gray;}
|
||||
#page-admin-qbehaviours th {white-space: normal;}
|
||||
|
||||
@@ -93,7 +93,8 @@
|
||||
}
|
||||
|
||||
#page-admin-report-backups-index .backup-skipped,
|
||||
#page-admin-report-backups-index .backup-ok {
|
||||
#page-admin-report-backups-index .backup-ok,
|
||||
#page-admin-report-backups-index .backup-notyetrun {
|
||||
color: @successText;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user