2007-09-08 22:36:29 +00:00
|
|
|
<?php // $Id$
|
|
|
|
// index.php - scheduled backup logs
|
|
|
|
|
|
|
|
require_once('../../../config.php');
|
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
require_once($CFG->dirroot.'/backup/lib.php');
|
|
|
|
|
|
|
|
$courseid = optional_param('courseid', 0, PARAM_INT);
|
|
|
|
|
2008-11-26 19:27:39 +00:00
|
|
|
admin_externalpage_setup('reportbackups');
|
|
|
|
admin_externalpage_print_header();
|
2007-09-08 22:36:29 +00:00
|
|
|
|
|
|
|
/// Scheduled backups are disabled by the server admin
|
|
|
|
if (!empty($CFG->disablescheduledbackups)) {
|
2008-04-10 05:58:13 +00:00
|
|
|
print_error('scheduledbackupsdisabled', 'error');
|
2007-09-08 22:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Scheduled backups aren't active by the site admin
|
|
|
|
$backup_config = backup_get_config();
|
|
|
|
if (empty($backup_config->backup_sche_active)) {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification(get_string('scheduledbackupsinactive'));
|
2007-09-08 22:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Get needed strings
|
|
|
|
$backuploglaststatus = get_string("backuploglaststatus");
|
|
|
|
$backuplogdetailed = get_string("backuplogdetailed");
|
|
|
|
$stradmin = get_string("administration");
|
|
|
|
$strconfiguration = get_string("configuration");
|
|
|
|
$strbackup = get_string("backup");
|
|
|
|
$strbackupdetails = get_string("backupdetails");
|
|
|
|
$strlogs = get_string("logs");
|
|
|
|
$strftimedatetime = get_string("strftimerecent");
|
|
|
|
$strftimetime = get_string("strftimetime").":%S";
|
|
|
|
$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");
|
|
|
|
$strnext = get_string("next");
|
|
|
|
|
|
|
|
/// Decide when to show last execution logs or detailed logs
|
|
|
|
/// Lastlog view
|
|
|
|
if (!$courseid) {
|
2009-08-06 08:17:12 +00:00
|
|
|
echo $OUTPUT->heading($backuploglaststatus);
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box_start();
|
2007-09-08 22:36:29 +00:00
|
|
|
/// Now, get every record from backup_courses
|
2008-05-31 14:35:58 +00:00
|
|
|
$courses = $DB->get_records("backup_courses");
|
2007-09-08 22:36:29 +00:00
|
|
|
|
|
|
|
if (!$courses) {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification(get_string('nologsfound'));
|
2007-09-08 22:36:29 +00:00
|
|
|
} else {
|
|
|
|
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
|
|
|
//Print table header
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strcourse</font></td>";
|
|
|
|
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\"><font size=\"3\">$strtimetaken</font></td>";
|
|
|
|
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strstatus</font></td>";
|
|
|
|
echo "<td nowrap=\"nowrap\" align=\"center\"><font size=\"3\">$strnext</font></td></tr>";
|
|
|
|
foreach ($courses as $course) {
|
|
|
|
/// Get the course shortname
|
2008-06-02 21:39:23 +00:00
|
|
|
$coursename = $DB->get_field ("course", "fullname", array("id"=>$course->courseid));
|
2007-09-08 22:36:29 +00:00
|
|
|
if ($coursename) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\"><a href=\"index.php?courseid=$course->courseid\">".$coursename."</a></font></td>";
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->laststarttime,$strftimedatetime)."</font></td>";
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\"> - </font></td>";
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->lastendtime,$strftimedatetime)."</font></td>";
|
|
|
|
if ($course->laststatus == 1) {
|
|
|
|
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>";
|
|
|
|
}
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($course->nextstarttime,$strftimedatetime)."</font></td>";
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
}
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2007-09-08 22:36:29 +00:00
|
|
|
/// Detailed View !!
|
|
|
|
} else {
|
2009-08-06 08:17:12 +00:00
|
|
|
echo $OUTPUT->heading($backuplogdetailed);
|
2007-09-08 22:36:29 +00:00
|
|
|
|
2008-06-02 21:39:23 +00:00
|
|
|
$coursename = $DB->get_field("course", "fullname", array("id"=>"$courseid"));
|
2009-08-06 08:17:12 +00:00
|
|
|
echo $OUTPUT->heading("$strcourse: $coursename");
|
2007-09-08 22:36:29 +00:00
|
|
|
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box_start();
|
2007-09-08 22:36:29 +00:00
|
|
|
|
|
|
|
/// First, me get all the distinct backups for that course in backup_log
|
2008-05-31 14:35:58 +00:00
|
|
|
$executions = $DB->get_records_sql("SELECT DISTINCT laststarttime,laststarttime
|
|
|
|
FROM {backup_log}
|
2009-03-03 00:06:08 +00:00
|
|
|
WHERE courseid = ? AND backuptype = ?
|
|
|
|
ORDER BY laststarttime DESC", array($courseid,'scheduledbackup'));
|
2007-09-08 22:36:29 +00:00
|
|
|
|
|
|
|
/// Iterate over backup executions
|
|
|
|
if (!$executions) {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification(get_string('nologsfound'));
|
2007-09-08 22:36:29 +00:00
|
|
|
} else {
|
|
|
|
echo "<table border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">";
|
|
|
|
foreach($executions as $execution) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td nowrap=\"nowrap\" align=\"center\" colspan=\"3\">";
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box(userdate($execution->laststarttime));
|
2007-09-08 22:36:29 +00:00
|
|
|
echo "</td>";
|
|
|
|
echo "</tr>";
|
2008-05-31 14:35:58 +00:00
|
|
|
$logs = $DB->get_records_sql("SELECT *
|
|
|
|
FROM {backup_log}
|
2009-03-03 00:06:08 +00:00
|
|
|
WHERE courseid = ? AND laststarttime = ? AND backuptype = ?
|
|
|
|
ORDER BY id", array($courseid, $execution->laststarttime,'scheduledbackup'));
|
2007-09-08 22:36:29 +00:00
|
|
|
if ($logs) {
|
|
|
|
foreach ($logs as $log) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\">".userdate($log->time,$strftimetime)."</font></td>";
|
|
|
|
$log->info = str_replace("- ERROR!!","- <font color=\"red\">ERROR!!</font>",$log->info);
|
|
|
|
$log->info = str_replace("- OK","- <font color=\"green\">OK</font>",$log->info);
|
|
|
|
echo "<td nowrap=\"nowrap\"><font size=\"2\">".str_replace(" "," ",$log->info)."</font></td>";
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
}
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2007-09-08 22:36:29 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|
2007-09-08 22:36:29 +00:00
|
|
|
|
|
|
|
?>
|