Skip to content

Commit

Permalink
Now, hidden courses that haven't been modified in the last month
Browse files Browse the repository at this point in the history
are skipped by the scheduled backup. Credit goes to James. Bug 4694.
(http://moodle.org/bugs/bug.php?op=show&bugid=4694)
  • Loading branch information
stronk7 committed May 1, 2006
1 parent e3ba25b commit 10d89cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backup/backup_scheduled.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ function schedule_backup_cron() {
if ($backup_course->nextstarttime > 0 && $backup_course->nextstarttime < $now) {
//We have to send a email because we have included at least one backup
$emailpending = true;
// Skip backup of unavailable courses that have remained unmodified in a month
if (!$course->visible && ($now - $course->timemodified) > 31) { //Hidden + unmodified last month
//if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
mtrace(" SKIPPING - hidden+unmodified");
set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
continue;
}
//Only make the backup if laststatus isn't 2-UNFINISHED (uncontrolled error)
if ($backup_course->laststatus != 2) {
//Set laststarttime
Expand Down Expand Up @@ -154,13 +161,15 @@ function schedule_backup_cron() {
$count_ok = count_records('backup_courses','laststatus','1');
$count_error = count_records('backup_courses','laststatus','0');
$count_unfinished = count_records('backup_courses','laststatus','2');
$count_skipped = count_records('backup_courses','laststatus','3');

//Build the message text
//Summary
$message .= get_string('summary')."\n";
$message .= "==================================================\n";
$message .= " ".get_string('courses').": ".$count_all."\n";
$message .= " ".get_string('ok').": ".$count_ok."\n";
$message .= " ".get_string('skipped').": ".$count_skipped."\n";
$message .= " ".get_string('error').": ".$count_error."\n";
$message .= " ".get_string('unfinished').": ".$count_unfinished."\n\n";

Expand Down
3 changes: 3 additions & 0 deletions backup/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$strerror = get_string("error");
$strok = get_string("ok");
$strunfinished = get_string("unfinished");
$strskipped = get_string("skipped");
$strcourse = get_string("course");
$strtimetaken = get_string("timetaken","quiz");
$strstatus = get_string("status");
Expand Down Expand Up @@ -71,6 +72,8 @@
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strok."</font></td>";
} else if ($course->laststatus == 2) {
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strunfinished."</font></td>";
} else if ($course->laststatus == 3) {
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"green\">".$strskipped."</font></td>";
} else {
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"2\" color=\"red\">".$strerror."</font></td>";
}
Expand Down

0 comments on commit 10d89cf

Please sign in to comment.