Merge branch 'MDL-30937_master' of https://github.com/markn86/moodle

This commit is contained in:
Dan Poltawski 2014-12-08 11:06:49 +00:00
commit aeb1fdd4e0
5 changed files with 110 additions and 12 deletions

View File

@ -66,7 +66,7 @@ abstract class backup_factory {
// Create database_logger, observing $CFG->backup_database_logger_level and defaulting to LOG_WARNING
// and pointing to the backup_logs table
$dllevel = isset($CFG->backup_database_logger_level) ? $CFG->backup_database_logger_level : backup::LOG_WARNING;
$dllevel = isset($CFG->backup_database_logger_level) ? $CFG->backup_database_logger_level : $dfltloglevel;
$columns = array('backupid' => $backupid);
$enabledloggers[] = new database_logger($dllevel, 'timecreated', 'loglevel', 'message', 'backup_logs', $columns);

BIN
pix/t/viewdetails.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

15
pix/t/viewdetails.svg Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
]>
<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"
xml:space="preserve" preserveAspectRatio="xMinYMid meet">
<defs>
</defs>
<path style="fill:#999999;" d="M11.4,9.4L9.9,7.9C9.8,7.8,9.7,7.8,9.6,7.7c0.4-0.8,0.7-1.6,0.7-2.5C10.3,2.3,8,0,5.2,0
C2.3,0,0,2.3,0,5.2s2.3,5.2,5.2,5.2c0.9,0,1.7-0.2,2.4-0.6C7.7,9.8,7.7,9.9,7.8,10l1.5,1.5c0.6,0.6,1.5,0.6,2.1,0S12,10,11.4,9.4z
M5.2,7.3C4,7.3,3,6.4,3,5.2C3,4,4,3,5.2,3c1.2,0,2.2,1,2.2,2.2C7.3,6.4,6.4,7.3,5.2,7.3z"/>
</svg>

After

Width:  |  Height:  |  Size: 974 B

View File

@ -24,13 +24,95 @@
*/
require_once('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir . '/adminlib.php');
// Required for backup::xxx constants.
require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php');
require_once($CFG->dirroot . '/backup/backup.class.php');
$courseid = optional_param('courseid', 0, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT); // This represents which backup we are viewing.
// 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'));
$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');
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid), 'id, fullname', MUST_EXIST);
// Get the automated backups that have been performed for this course.
$params = array('operation' => backup::OPERATION_BACKUP,
'type' => backup::TYPE_1COURSE,
'itemid' => $course->id,
'interactive' => backup::INTERACTIVE_NO);
if ($backups = $DB->get_records('backup_controllers', $params, 'timecreated DESC',
'id, backupid, status, timecreated', $page, 1)) {
// Get the backup we want to use.
$backup = reset($backups);
// Get the backup status.
if ($backup->status == backup::STATUS_FINISHED_OK) {
$status = $strok;
$statusclass = 'backup-ok'; // Green.
} else if ($backup->status == backup::STATUS_AWAITING || $backup->status == backup::STATUS_EXECUTING) {
$status = $strunfinished;
$statusclass = 'backup-unfinished'; // Red.
} else { // Else show error.
$status = $strerror;
$statusclass = 'backup-error'; // Red.
}
$table = new html_table();
$table->head = array('');
$table->data = array();
$statusrow = get_string('status') . ' - ' . html_writer::tag('span', $status, array('class' => $statusclass));
$table->data[] = array($statusrow);
// Get the individual logs for this backup.
if ($logs = $DB->get_records('backup_logs', array('backupid' => $backup->backupid), 'timecreated ASC',
'id, message, timecreated')) {
foreach ($logs as $log) {
$table->data[] = array(userdate($log->timecreated, get_string('strftimetime', 'report_backups')) .
' - ' . $log->message);
}
} else {
$table->data[] = array(get_string('nologsfound', 'report_backups'));
}
}
// Set the course name to display.
$coursename = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('backupofcourselogs', 'report_backups', $coursename));
if (isset($backup)) {
// We put this logic down here as we may be viewing a backup that was performed which there were no logs
// recorded for. We still want to display the pagination so the user can still navigate to other backups,
// and we also display a message so they are aware that the backup happened but there were no logs.
$baseurl = new moodle_url('/report/backups/index.php', array('courseid' => $courseid));
$numberofbackups = $DB->count_records('backup_controllers', $params);
$pagingbar = new paging_bar($numberofbackups, $page, 1, $baseurl);
echo $OUTPUT->render($pagingbar);
echo $OUTPUT->heading(get_string('logsofbackupexecutedon', 'report_backups', userdate($backup->timecreated)), 3);
echo html_writer::table($table);
echo $OUTPUT->render($pagingbar);
} else {
echo $OUTPUT->box(get_string('nobackupsfound', 'report_backups'), 'center');
}
echo $OUTPUT->footer();
exit();
}
$table = new html_table;
$table->head = array(
get_string("course"),
@ -42,17 +124,9 @@ $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');
$strnotyetrun = get_string('backupnotyetrun');
$select = ', ' . context_helper::get_preload_record_columns_sql('ctx');
$join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
$sql = "SELECT bc.*, c.fullname $select
$sql = "SELECT bc.*, c.id as courseid, c.fullname $select
FROM {backup_courses} bc
JOIN {course} c ON c.id = bc.courseid
$join";
@ -86,8 +160,11 @@ foreach ($rs as $backuprow) {
$status->attributes = array('class' => $statusclass);
// Create the row and add it to the table
$backuprowname = format_string($backuprow->fullname, true, array('context' => context_course::instance($backuprow->courseid)));
$backuplogsurl = new moodle_url('/report/backups/index.php', array('courseid' => $backuprow->courseid));
$backuplogsicon = new pix_icon('t/viewdetails', get_string('viewlogs', 'report_backups'));
$cells = array(
format_string($backuprow->fullname, true, array('context' => context_course::instance($backuprow->courseid))),
$backuprowname . ' ' . $OUTPUT->action_icon($backuplogsurl, $backuplogsicon),
userdate($backuprow->laststarttime, $strftimedatetime),
'-',
userdate($backuprow->lastendtime, $strftimedatetime),

View File

@ -23,4 +23,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['backupofcourselogs'] = 'Backup logs of {$a}';
$string['logsofbackupexecutedon'] = 'Logs of the backup executed on {$a}';
$string['nobackupsfound'] = 'There were no backups found.';
$string['nologsfound'] = 'There were no logs found for this backup.';
$string['pluginname'] = 'Backups report';
$string['strftimetime'] = '%I:%M:%S %p';
$string['viewlogs'] = 'View logs';