Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   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  
  26  require(__DIR__.'/../../config.php');
  27  require_once($CFG->libdir.'/adminlib.php');
  28  
  29  // Allow searching by setting when providing parameter directly.
  30  $search = optional_param('search', '', PARAM_TEXT);
  31  
  32  admin_externalpage_setup('reportconfiglog', '', ['search' => $search], '', ['pagelayout' => 'report']);
  33  
  34  echo $OUTPUT->header();
  35  echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
  36  
  37  /** @var cache_session $cache */
  38  $cache = cache::make_from_params(cache_store::MODE_SESSION, 'report_customlog', 'search');
  39  
  40  if (!empty($search)) {
  41      $searchdata = (object) ['setting' => $search];
  42  } else {
  43      $searchdata = $cache->get('data');
  44  }
  45  
  46  $mform = new \report_configlog\form\search();
  47  $mform->set_data($searchdata);
  48  
  49  $searchclauses = [];
  50  
  51  // Check if we have a form submission, or a cached submission.
  52  $data = ($mform->is_submitted() ? $mform->get_data() : fullclone($searchdata));
  53  if ($data instanceof stdClass) {
  54      if (!empty($data->value)) {
  55          $searchclauses[] = $data->value;
  56      }
  57      if (!empty($data->setting)) {
  58          $searchclauses[] = "setting:{$data->setting}";
  59      }
  60      if (!empty($data->user)) {
  61          $searchclauses[] = "user:{$data->user}";
  62      }
  63      if (!empty($data->datefrom)) {
  64          $searchclauses[] = "datefrom:{$data->datefrom}";
  65      }
  66      if (!empty($data->dateto)) {
  67          $dateto = $data->dateto + DAYSECS - 1;
  68          $searchclauses[] = "dateto:{$dateto}";
  69      }
  70  
  71      // Cache form submission so that it is preserved while paging through the report.
  72      unset($data->submitbutton);
  73      $cache->set('data', $data);
  74  }
  75  
  76  $mform->display();
  77  
  78  $table = new \report_configlog\output\report_table(implode(' ', $searchclauses));
  79  $table->define_baseurl($PAGE->url);
  80  
  81  echo $PAGE->get_renderer('report_configlog')->render($table);
  82  
  83  echo $OUTPUT->footer();