From: stronk7 Date: Sat, 8 Sep 2007 22:36:29 +0000 (+0000) Subject: Adding new report to display scheduled backup logs. MDL-7850 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=834479c28c42adb2178cd918c893f8d08798fdb5;p=moodle.git Adding new report to display scheduled backup logs. MDL-7850 Merged from MOODLE_18_STABLE --- diff --git a/admin/report/backups/index.php b/admin/report/backups/index.php new file mode 100644 index 0000000000..d7fab79915 --- /dev/null +++ b/admin/report/backups/index.php @@ -0,0 +1,140 @@ +libdir.'/adminlib.php'); + require_once($CFG->dirroot.'/backup/lib.php'); + + $adminroot = admin_get_root(); + + admin_externalpage_setup('reportbackups', $adminroot); + + admin_externalpage_print_header($adminroot); + + $courseid = optional_param('courseid', 0, PARAM_INT); + + require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID)); + +/// Scheduled backups are disabled by the server admin + if (!empty($CFG->disablescheduledbackups)) { + print_error('scheduledbackupsdisabled', '', '', NULL, true); + } + +/// Scheduled backups aren't active by the site admin + $backup_config = backup_get_config(); + if (empty($backup_config->backup_sche_active)) { + notify(get_string('scheduledbackupsinactive')); + } + +/// 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) { + print_heading($backuploglaststatus); + print_simple_box_start('center'); + /// Now, get every record from backup_courses + $courses = get_records("backup_courses"); + + if (!$courses) { + notify(get_string('nologsfound')); + } else { + echo ""; + //Print table header + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + foreach ($courses as $course) { + /// Get the course shortname + $coursename = get_field ("course","fullname","id",$course->courseid); + if ($coursename) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + if ($course->laststatus == 1) { + echo ""; + } else if ($course->laststatus == 2) { + echo ""; + } else if ($course->laststatus == 3) { + echo ""; + } else { + echo ""; + } + echo ""; + echo ""; + } + } + echo "
$strcourse$strtimetaken$strstatus$strnext
courseid\">".$coursename."".userdate($course->laststarttime,$strftimedatetime)." - ".userdate($course->lastendtime,$strftimedatetime)."".$strok."".$strunfinished."".$strskipped."".$strerror."".userdate($course->nextstarttime,$strftimedatetime)."
"; + } + print_simple_box_end(); +/// Detailed View !! + } else { + print_heading($backuplogdetailed); + + $coursename = get_field("course","fullname","id","$courseid"); + print_heading("$strcourse: $coursename"); + + print_simple_box_start('center'); + + /// First, me get all the distinct backups for that course in backup_log + $executions = get_records_sql("SELECT DISTINCT laststarttime,laststarttime + FROM {$CFG->prefix}backup_log + WHERE courseid = '$courseid' + ORDER BY laststarttime DESC"); + + /// Iterate over backup executions + if (!$executions) { + notify(get_string('nologsfound')); + } else { + echo ""; + foreach($executions as $execution) { + echo ""; + echo ""; + echo ""; + $logs = get_records_sql("SELECT * + FROM {$CFG->prefix}backup_log + WHERE courseid = '$courseid' AND + laststarttime = '$execution->laststarttime' + ORDER BY id"); + if ($logs) { + foreach ($logs as $log) { + echo ""; + echo ""; + $log->info = str_replace("- ERROR!!","- ERROR!!",$log->info); + $log->info = str_replace("- OK","- OK",$log->info); + echo ""; + echo ""; + } + } + } + echo "
"; + print_simple_box("
".userdate($execution->laststarttime)."
", "center"); + echo "
".userdate($log->time,$strftimetime)."".str_replace(" ","    ",$log->info)."
"; + } + print_simple_box_end(); + } + + admin_externalpage_print_footer($adminroot); + +?>