MDL-53034 mod_quiz: New WS mod_quiz_get_quiz_feedback_for_grade
[moodle.git] / admin / reports.php
blobe4db14993dfdd4c4b49f0bc0a8d305da55cde1c0
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Provides an overview of installed reports
20 * Displays the list of found reports, their version (if found) and
21 * a link to uninstall the report.
23 * The code is based on admin/localplugins.php by David Mudrak.
25 * @package admin
26 * @copyright 2011 Petr Skoda {@link http://skodak.org}
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 require_once(dirname(__FILE__) . '/../config.php');
31 require_once($CFG->libdir.'/adminlib.php');
32 require_once($CFG->libdir.'/tablelib.php');
34 admin_externalpage_setup('managereports');
36 echo $OUTPUT->header();
37 echo $OUTPUT->heading(get_string('reports'));
39 /// Print the table of all installed report plugins
41 $struninstall = get_string('uninstallplugin', 'core_admin');
43 $table = new flexible_table('reportplugins_administration_table');
44 $table->define_columns(array('name', 'logstoressupported', 'version', 'uninstall'));
45 $table->define_headers(array(get_string('plugin'), get_string('logstoressupported', 'admin'), get_string('version'),
46 $struninstall));
47 $table->define_baseurl($PAGE->url);
48 $table->set_attribute('id', 'reportplugins');
49 $table->set_attribute('class', 'admintable generaltable');
50 $table->setup();
52 $plugins = array();
53 $availableplugins = core_component::get_plugin_list('report');
54 foreach ($availableplugins as $plugin => $plugindir) {
55 if (get_string_manager()->string_exists('pluginname', 'report_' . $plugin)) {
56 $strpluginname = get_string('pluginname', 'report_' . $plugin);
57 } else {
58 $strpluginname = $plugin;
60 $plugins[$plugin] = $strpluginname;
62 core_collator::asort($plugins);
64 $like = $DB->sql_like('plugin', '?', true, true, false, '|');
65 $params = array('report|_%');
66 $installed = $DB->get_records_select('config_plugins', "$like AND name = 'version'", $params);
67 $versions = array();
68 foreach ($installed as $config) {
69 $name = preg_replace('/^report_/', '', $config->plugin);
70 $versions[$name] = $config->value;
71 if (!isset($plugins[$name])) {
72 $plugins[$name] = $name;
76 $logmanager = get_log_manager();
78 foreach ($plugins as $plugin => $name) {
79 $uninstall = '';
80 if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('report_'.$plugin, 'manage')) {
81 $uninstall = html_writer::link($uninstallurl, $struninstall);
84 $stores = array();
85 if (isset($availableplugins[$plugin])) {
86 $stores = $logmanager->get_supported_logstores('report_' . $plugin);
88 if ($stores === false) {
89 $supportedstores = get_string('logstorenotrequired', 'admin');
90 } else if (!empty($stores)) {
91 $supportedstores = implode(', ', $stores);
92 } else {
93 $supportedstores = get_string('nosupportedlogstore', 'admin');;
96 if (!isset($versions[$plugin])) {
97 if (file_exists("$CFG->dirroot/report/$plugin/version.php")) {
98 // not installed yet
99 $version = '?';
100 } else {
101 // no version info available
102 $version = '-';
104 } else {
105 $version = $versions[$plugin];
106 if (file_exists("$CFG->dirroot/report/$plugin")) {
107 $version = $versions[$plugin];
108 } else {
109 // somebody removed plugin without uninstall
110 $name = '<span class="notifyproblem">'.$name.' ('.get_string('missingfromdisk').')</span>';
111 $version = $versions[$plugin];
115 $table->add_data(array($name, $supportedstores, $version, $uninstall));
118 $table->print_html();
120 echo $OUTPUT->footer();