2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Config changes report
21 * @subpackage configlog
22 * @copyright 2009 Petr Skoda
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require(dirname(__FILE__
).'/../../config.php');
27 require_once($CFG->libdir
.'/adminlib.php');
30 $page = optional_param('page', 0, PARAM_INT
);
31 $perpage = optional_param('perpage', 30, PARAM_INT
); // how many per page
32 $sort = optional_param('sort', 'timemodified', PARAM_ALPHA
);
33 $dir = optional_param('dir', 'DESC', PARAM_ALPHA
);
35 admin_externalpage_setup('reportconfiglog', '', null, '', array('pagelayout'=>'report'));
36 echo $OUTPUT->header();
38 echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
40 $changescount = $DB->count_records('config_log');
42 $columns = array('firstname' => get_string('firstname'),
43 'lastname' => get_string('lastname'),
44 'timemodified' => get_string('timemodified', 'report_configlog'),
45 'plugin' => get_string('plugin', 'report_configlog'),
46 'name' => get_string('setting', 'report_configlog'),
47 'value' => get_string('value', 'report_configlog'),
48 'oldvalue' => get_string('oldvalue', 'report_configlog'),
53 if (!isset($columns[$sort])) {
57 foreach ($columns as $column=>$strcolumn) {
58 if ($sort != $column) {
60 if ($column == 'lastaccess') {
66 $columndir = $dir == 'ASC' ?
'DESC':'ASC';
67 if ($column == 'lastaccess') {
68 $columnicon = $dir == 'ASC' ?
'up':'down';
70 $columnicon = $dir == 'ASC' ?
'down':'up';
72 $columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
75 $hcolumns[$column] = "<a href=\"index.php?sort=$column&dir=$columndir&page=$page&perpage=$perpage\">".$strcolumn."</a>$columnicon";
78 $baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
79 echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
81 $override = new stdClass();
82 $override->firstname
= 'firstname';
83 $override->lastname
= 'lastname';
84 $fullnamelanguage = get_string('fullnamedisplay', '', $override);
85 if (($CFG->fullnamedisplay
== 'firstname lastname') or
86 ($CFG->fullnamedisplay
== 'firstname') or
87 ($CFG->fullnamedisplay
== 'language' and $fullnamelanguage == 'firstname lastname' )) {
88 $fullnamedisplay = $hcolumns['firstname'].' / '.$hcolumns['lastname'];
89 } else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname')
90 $fullnamedisplay = $hcolumns['lastname'].' / '.$hcolumns['firstname'];
93 $table = new html_table();
94 $table->head
= array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']);
95 $table->colclasses
= array('leftalign date', 'leftalign name', 'leftalign plugin', 'leftalign setting', 'leftalign newvalue', 'leftalign originalvalue');
96 $table->id
= 'configchanges';
97 $table->attributes
['class'] = 'admintable generaltable';
98 $table->data
= array();
100 if ($sort == 'firstname' or $sort == 'lastname') {
101 $orderby = "u.$sort $dir";
102 } else if ($sort == 'value' or $sort == 'oldvalue') {
103 // cross-db text-compatible sorting.
104 $orderby = $DB->sql_order_by_text("cl.$sort", 255) . ' ' . $dir;
106 $orderby = "cl.$sort $dir";
109 $ufields = user_picture
::fields('u');
110 $sql = "SELECT $ufields,
111 cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue
113 JOIN {user} u ON u.id = cl.userid
116 $rs = $DB->get_recordset_sql($sql, array(), $page*$perpage, $perpage);
117 foreach ($rs as $log) {
119 $row[] = userdate($log->timemodified
);
120 $row[] = fullname($log);
121 if (is_null($log->plugin
)) {
124 $row[] = $log->plugin
;
127 $row[] = s($log->value
);
128 $row[] = s($log->oldvalue
);
130 $table->data
[] = $row;
134 echo html_writer
::table($table);
136 echo $OUTPUT->footer();