Skip to content
Snippets Groups Projects
Unverified Commit 113f43f6 authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Added a new settings page for displaying course backups

parent de9b8e0a
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,28 @@ class admin_page_active_processes extends \admin_externalpage { ...@@ -50,6 +50,28 @@ class admin_page_active_processes extends \admin_externalpage {
} }
} }
/**
* External Page for showing course backups
*
* @package tool_cleanupcourses
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_page_course_backups extends \admin_externalpage {
/**
* The constructor - calls parent constructor
*
*/
public function __construct() {
$url = new \moodle_url('/admin/tool/cleanupcourses/coursebackups.php');
parent::__construct('tool_cleanupcourses_coursebackups',
get_string('course_backups_list_header', 'tool_cleanupcourses'),
$url);
}
}
/** /**
* External Page for defining settings for subplugins * External Page for defining settings for subplugins
* *
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Table listing course backups
*
* @package tool_cleanupcourses
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\table;
defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
class course_backups_table extends \table_sql {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
global $PAGE;
$this->set_sql('b.*',
'{tool_cleanupcourses_backups} b',
"TRUE");
$this->define_baseurl($PAGE->url);
$this->init();
}
public function init() {
$this->define_columns(['courseid', 'courseshortname', 'coursefullname', 'backupcreated']);
$this->define_headers([
get_string('course'),
get_string('shortnamecourse'),
get_string('fullnamecourse'),
get_string('backupcreated', 'tool_cleanupcourses')]);
$this->setup();
}
/**
* Render courseid column.
* @param $row
* @return string course link
*/
public function col_courseid($row) {
try {
return \html_writer::link(course_get_url($row->courseid), $row->courseid);
} catch (\dml_missing_record_exception $e) {
return $row->courseid;
}
}
/**
* Render courseshortname column.
* @param $row
* @return string course link
*/
public function col_courseshortname($row) {
try {
return \html_writer::link(course_get_url($row->courseid), $row->shortname);
} catch (\dml_missing_record_exception $e) {
return $row->shortname;
}
}
/**
* Render coursefullname column.
* @param $row
* @return string course link
*/
public function col_coursefullname($row) {
try {
return \html_writer::link(course_get_url($row->courseid), $row->fullname);
} catch (\dml_missing_record_exception $e) {
return $row->fullname;
}
}
/**
* Render backupcreated column.
* @param $row
* @return string date of the backupcreated
*/
public function col_backupcreated($row) {
return userdate($row->backupcreated);
}
}
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Display the list of all course backups
*
* @package tool_cleanupcourses
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../../config.php');
require_login();
require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('tool_cleanupcourses_activeprocesses');
$PAGE->set_context(context_system::instance());
$PAGE->set_url(new \moodle_url('/admin/tool/cleanupcourses/coursebackups.php'));
$table = new tool_cleanupcourses\table\course_backups_table('tool_cleanupcourses_course_backups');
$PAGE->set_title("Title");
$PAGE->set_heading("Heading");
$renderer = $PAGE->get_renderer('tool_cleanupcourses');
echo $renderer->header();
$table->out(50, false);
echo $renderer->footer();
...@@ -70,3 +70,6 @@ $string['nostepfound'] = 'A step with the given stepid could not be found!'; ...@@ -70,3 +70,6 @@ $string['nostepfound'] = 'A step with the given stepid could not be found!';
$string['noprocessfound'] = 'A process with the given processid could not be found!'; $string['noprocessfound'] = 'A process with the given processid could not be found!';
$string['nocoursestodisplay'] = 'There are currently no courses, which require your attention!'; $string['nocoursestodisplay'] = 'There are currently no courses, which require your attention!';
$string['course_backups_list_header'] = 'Course Backups';
$string['backupcreated'] = 'Created at';
...@@ -39,6 +39,7 @@ if ($hassiteconfig) { ...@@ -39,6 +39,7 @@ if ($hassiteconfig) {
183 * 24 * 60 * 60)); // Dafault value is 180 days. 183 * 24 * 60 * 60)); // Dafault value is 180 days.
$ADMIN->add('cleanupcourses_category', new tool_cleanupcourses\admin_page_active_processes()); $ADMIN->add('cleanupcourses_category', new tool_cleanupcourses\admin_page_active_processes());
$ADMIN->add('cleanupcourses_category', new tool_cleanupcourses\admin_page_course_backups());
$ADMIN->add('cleanupcourses_category', new tool_cleanupcourses\admin_page_sublugins()); $ADMIN->add('cleanupcourses_category', new tool_cleanupcourses\admin_page_sublugins());
if ($ADMIN->fulltree) { if ($ADMIN->fulltree) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment