diff --git a/backup/util/helper/backup_cron_helper.class.php b/backup/util/helper/backup_cron_helper.class.php index 7c6de1e4182..7e015100588 100644 --- a/backup/util/helper/backup_cron_helper.class.php +++ b/backup/util/helper/backup_cron_helper.class.php @@ -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; @@ -119,12 +121,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. @@ -228,16 +231,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) { @@ -300,7 +304,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'); diff --git a/lang/en/moodle.php b/lang/en/moodle.php index a7bcc3066af..3f4ba028be7 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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 Backup FAQ 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
(leave blank to save in its course default dir)'; diff --git a/report/backups/index.php b/report/backups/index.php index 1deaa2dca3d..ca9844544c2 100644 --- a/report/backups/index.php +++ b/report/backups/index.php @@ -43,12 +43,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 @@ -61,22 +62,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); @@ -115,4 +119,4 @@ if (empty($automatedbackupsenabled)) { } echo html_writer::table($table); echo $OUTPUT->box_end(); -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/theme/base/style/admin.css b/theme/base/style/admin.css index 6a46a380813..b01e3d96a4b 100644 --- a/theme/base/style/admin.css +++ b/theme/base/style/admin.css @@ -44,6 +44,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;}