Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/backups/index.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 require_once('../../config.php');
00027 require_once($CFG->libdir.'/adminlib.php');
00028 require_once($CFG->dirroot.'/backup/lib.php');
00029 
00030 admin_externalpage_setup('reportbackups', '', null, '', array('pagelayout'=>'report'));
00031 
00032 $table = new html_table;
00033 $table->head = array(
00034     get_string("course"),
00035     get_string("timetaken", "quiz"),
00036     get_string("status"),
00037     get_string("backupnext")
00038 );
00039 $table->headspan = array(1, 3, 1, 1);
00040 $table->attributes = array('class' => 'generaltable backup-report');
00041 $table->data = array();
00042 
00043 $strftimedatetime = get_string("strftimerecent");
00044 $strerror = get_string("error");
00045 $strok = get_string("ok");
00046 $strunfinished = get_string("unfinished");
00047 $strskipped = get_string("skipped");
00048 
00049 list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
00050 $sql = "SELECT bc.*, c.fullname $select
00051           FROM {backup_courses} bc
00052           JOIN {course} c ON c.id = bc.courseid
00053                $join";
00054 $rs = $DB->get_recordset_sql($sql);
00055 foreach ($rs as $backuprow) {
00056 
00057     // Cache the course context
00058     context_instance_preload($backuprow);
00059 
00060     // Prepare a cell to display the status of the entry
00061     if ($backuprow->laststatus == 1) {
00062         $status = $strok;
00063         $statusclass = 'backup-ok'; // Green
00064     } else if ($backuprow->laststatus == 2) {
00065         $status = $strunfinished;
00066         $statusclass = 'backup-unfinished'; // Red
00067     } else if ($backuprow->laststatus == 3) {
00068         $status = $strskipped;
00069         $statusclass = 'backup-skipped'; // Green
00070     } else {
00071         $status = $strerror;
00072         $statusclass = 'backup-error'; // Red
00073     }
00074     $status = new html_table_cell($status);
00075     $status->attributes = array('class' => $statusclass);
00076 
00077     // Create the row and add it to the table
00078     $cells = array(
00079         format_string($backuprow->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $backuprow->courseid))),
00080         userdate($backuprow->laststarttime, $strftimedatetime),
00081         '-',
00082         userdate($backuprow->lastendtime, $strftimedatetime),
00083         $status,
00084         userdate($backuprow->nextstarttime, $strftimedatetime)
00085     );
00086     $table->data[] = new html_table_row($cells);
00087 }
00088 $rs->close();
00089 
00090 // Check if we have any results and if not add a no records notification
00091 if (empty($table->data)) {
00092     $cell = new html_table_cell($OUTPUT->notification(get_string('nologsfound')));
00093     $cell->colspan = 6;
00094     $table->data[] = new html_table_row(array($cell));
00095 }
00096 
00097 $automatedbackupsenabled = get_config('backup', 'backup_auto_active');
00098 
00099 // Display the backup report
00100 echo $OUTPUT->header();
00101 echo $OUTPUT->heading(get_string("backuploglaststatus"));
00102 echo $OUTPUT->box_start();
00103 if (empty($automatedbackupsenabled)) {
00104     // Automated backups aren't active, display a notification.
00105     // Not we don't stop because of this as perhaps scheduled backups are being run
00106     // automatically, or were enabled in the page.
00107     echo $OUTPUT->notification(get_string('automatedbackupsinactive', 'backup'));
00108 }
00109 echo html_writer::table($table);
00110 echo $OUTPUT->box_end();
00111 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations