3 require_once(dirname(__FILE__).'/../../../config.php');
4 require_once($CFG->libdir.'/adminlib.php');
7 $page = optional_param('page', 0, PARAM_INT);
8 $perpage = optional_param('perpage', 30, PARAM_INT); // how many per page
9 $sort = optional_param('sort', 'timemodified', PARAM_ALPHA);
10 $dir = optional_param('dir', 'DESC', PARAM_ALPHA);
12 admin_externalpage_setup('reportconfiglog');
13 echo $OUTPUT->header();
15 echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
17 $changescount = $DB->count_records('config_log');
19 $columns = array('firstname' => get_string('firstname'),
20 'lastname' => get_string('lastname'),
21 'timemodified' => get_string('timemodified', 'report_configlog'),
22 'plugin' => get_string('plugin', 'report_configlog'),
23 'name' => get_string('setting', 'report_configlog'),
24 'value' => get_string('value', 'report_configlog'),
25 'oldvalue' => get_string('oldvalue', 'report_configlog'),
30 if (!isset($columns[$sort])) {
34 foreach ($columns as $column=>$strcolumn) {
35 if ($sort != $column) {
37 if ($column == 'lastaccess') {
43 $columndir = $dir == 'ASC' ? 'DESC':'ASC';
44 if ($column == 'lastaccess') {
45 $columnicon = $dir == 'ASC' ? 'up':'down';
47 $columnicon = $dir == 'ASC' ? 'down':'up';
49 $columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
52 $hcolumns[$column] = "<a href=\"index.php?sort=$column&dir=$columndir&page=$page&perpage=$perpage\">".$strcolumn."</a>$columnicon";
55 $baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
56 echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
58 $override = new stdClass();
59 $override->firstname = 'firstname';
60 $override->lastname = 'lastname';
61 $fullnamelanguage = get_string('fullnamedisplay', '', $override);
62 if (($CFG->fullnamedisplay == 'firstname lastname') or
63 ($CFG->fullnamedisplay == 'firstname') or
64 ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname' )) {
65 $fullnamedisplay = $hcolumns['firstname'].' / '.$hcolumns['lastname'];
66 } else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname')
67 $fullnamedisplay = $hcolumns['lastname'].' / '.$hcolumns['firstname'];
70 $table = new html_table();
71 $table->head = array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']);
72 $table->align = array('left', 'left', 'left', 'left', 'left', 'left');
73 $table->size = array('30%', '10%', '10%', '10%', '20%', '20%');
74 $table->width = '95%';
75 $table->data = array();
77 if ($sort == 'firstname' or $sort == 'lastname') {
78 $orderby = "u.$sort $dir";
80 $orderby = "cl.$sort $dir";
83 $ufields = user_picture::fields('u');
84 $sql = "SELECT $ufields,
85 cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue
87 JOIN {user} u ON u.id = cl.userid
90 $rs = $DB->get_recordset_sql($sql, array(), $page*$perpage, $perpage);
91 foreach ($rs as $log) {
93 $row[] = userdate($log->timemodified);
94 $row[] = fullname($log);
95 if (is_null($log->plugin)) {
98 $row[] = $log->plugin;
101 $row[] = s($log->value);
102 $row[] = s($log->oldvalue);
104 $table->data[] = $row;
108 echo html_writer::table($table);
110 echo $OUTPUT->footer();