diff --git a/classes/output/renderer.php b/classes/output/renderer.php deleted file mode 100644 index 0bfe1ff..0000000 --- a/classes/output/renderer.php +++ /dev/null @@ -1,49 +0,0 @@ -. - -namespace report_upgradelog\output; - -use plugin_renderer_base; - -/** - * Plugin renderer - * - * @package report_upgradelog - * @copyright 2019 Paul Holden - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class renderer extends plugin_renderer_base { - - /** @var int Page size for displaying report table. */ - const REPORT_TABLE_PAGESIZE = 30; - - /** - * Render the report table - * - * @param report_table $table - * @return string - */ - protected function render_report_table(report_table $table): string { - ob_start(); - - $table->out(self::REPORT_TABLE_PAGESIZE, false); - $output = ob_get_contents(); - - ob_end_clean(); - - return $output; - } -} diff --git a/classes/output/report_table.php b/classes/output/report_table.php deleted file mode 100644 index 7cfaae9..0000000 --- a/classes/output/report_table.php +++ /dev/null @@ -1,144 +0,0 @@ -. - -namespace report_upgradelog\output; - -use renderable; -use stdClass; -use table_sql; -use core_user\fields; -use report_upgradelog\version_helper; - -defined('MOODLE_INTERNAL') || die; - -global $CFG; -require_once($CFG->libdir . '/tablelib.php'); - -/** - * Report table - * - * @package report_upgradelog - * @copyright 2019 Paul Holden - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class report_table extends table_sql implements renderable { - - /** - * Class constructor - */ - public function __construct() { - parent::__construct('report-upgradelog-report-table'); - - // Define columns. - $columns = [ - 'fullname' => null, - 'info' => get_string('info'), - 'moodleversion' => get_string('moodleversion'), - 'moodlerelease' => get_string('moodlerelease'), - 'timemodified' => get_string('time'), - ]; - - $this->define_columns(array_keys($columns)); - $this->define_headers(array_values($columns)); - - // Table configuration. - $this->set_attribute('cellspacing', '0'); - - $this->sortable(true, 'timemodified', SORT_DESC); - $this->no_sorting('moodlerelease'); - - $this->initialbars(false); - $this->collapsible(false); - - $this->useridfield = 'userid'; - - // Initialize table SQL properties. - $this->init_sql(); - } - - /** - * Helper method to ensure appropriate method is called to retrieve user name fields - * - * @param string $usertablealias - * @return string - */ - private function user_name_fields(string $usertablealias): string { - if (class_exists(fields::class)) { - return fields::for_name()->get_sql($usertablealias, false, '', '', false)->selects; - } - - return get_all_user_name_fields(true, $usertablealias); - } - - /** - * Initializes table SQL properties - */ - protected function init_sql(): void { - global $DB; - - $fields = 'ul.timemodified, ul.userid, ul.info, ul.version AS moodleversion, 0 AS moodlerelease, ' . - $this->user_name_fields('u'); - - $from = '{upgrade_log} ul LEFT JOIN {user} u ON u.id = ul.userid'; - - list($infowhere, $params) = $DB->get_in_or_equal(['Core installed', 'Core upgraded'], SQL_PARAMS_NAMED); - $where = "ul.plugin = :plugin AND {$DB->sql_compare_text('ul.info')} {$infowhere}"; - $params['plugin'] = 'core'; - - $this->set_sql($fields, $from, $where, $params); - $this->set_count_sql("SELECT COUNT(1) FROM {$from} WHERE {$where}", $params); - } - - /** - * Format information column - * - * @param stdClass $row - * @return string - */ - public function col_info(stdClass $row): string { - return $this->format_text($row->info, FORMAT_PLAIN); - } - - /** - * Format Moodle version column - * - * @param stdClass $row - * @return string - */ - public function col_moodleversion(stdClass $row): string { - return version_helper::get_version_string($row->moodleversion); - } - - /** - * Format Moodle release column - * - * @param stdClass $row - * @return string - */ - public function col_moodlerelease(stdClass $row): string { - return version_helper::get_release_name($row->moodleversion); - } - - /** - * Format time modified column - * - * @param stdClass $row - * @return string - */ - public function col_timemodified(stdClass $row): string { - return userdate($row->timemodified); - } -} diff --git a/index.php b/index.php index 43df7bc..82c7892 100644 --- a/index.php +++ b/index.php @@ -34,13 +34,7 @@ echo $OUTPUT->heading_with_help(get_string('pluginname', 'report_upgradelog'), 'upgrades', 'report_upgradelog'); -// Check for presence of reportbuilder. -if (class_exists(system_report_factory::class)) { - $report = system_report_factory::create(upgrades::class, context_system::instance()); - echo $report->output(); -} else { - ($table = new \report_upgradelog\output\report_table())->define_baseurl($PAGE->url); - echo $PAGE->get_renderer('report_upgradelog')->render($table); -} +$report = system_report_factory::create(upgrades::class, context_system::instance()); +echo $report->output(); echo $OUTPUT->footer();