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.
13//
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/>.
16
17/**
18 * Config changes report
19 *
20 * @package    report
21 * @subpackage configlog
22 * @copyright  2009 Petr Skoda
23 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26require(__DIR__.'/../../config.php');
27require_once($CFG->libdir.'/adminlib.php');
28
29admin_externalpage_setup('reportconfiglog', '', null, '', array('pagelayout'=>'report'));
30
31echo $OUTPUT->header();
32echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
33
34$mform = new \report_configlog\form\search();
35
36/** @var cache_session $cache */
37$cache = cache::make_from_params(cache_store::MODE_SESSION, 'report_customlog', 'search');
38if ($cachedata = $cache->get('data')) {
39    $mform->set_data($cachedata);
40}
41
42$searchclauses = [];
43
44// Check if we have a form submission, or a cached submission.
45$data = ($mform->is_submitted() ? $mform->get_data() : fullclone($cachedata));
46if ($data instanceof stdClass) {
47    if (!empty($data->value)) {
48        $searchclauses[] = $data->value;
49    }
50    if (!empty($data->setting)) {
51        $searchclauses[] = "setting:{$data->setting}";
52    }
53    if (!empty($data->user)) {
54        $searchclauses[] = "user:{$data->user}";
55    }
56    if (!empty($data->datefrom)) {
57        $searchclauses[] = "datefrom:{$data->datefrom}";
58    }
59    if (!empty($data->dateto)) {
60        $dateto = $data->dateto + DAYSECS - 1;
61        $searchclauses[] = "dateto:{$dateto}";
62    }
63
64    // Cache form submission so that it is preserved while paging through the report.
65    unset($data->submitbutton);
66    $cache->set('data', $data);
67}
68
69$mform->display();
70
71$table = new \report_configlog\output\report_table(implode(' ', $searchclauses));
72$table->define_baseurl($PAGE->url);
73
74echo $PAGE->get_renderer('report_configlog')->render($table);
75
76echo $OUTPUT->footer();