[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/report/configlog/ -> index.php (source)

   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  // page parameters
  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);
  34  
  35  admin_externalpage_setup('reportconfiglog', '', null, '', array('pagelayout'=>'report'));
  36  echo $OUTPUT->header();
  37  
  38  echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
  39  
  40  $changescount = $DB->count_records('config_log');
  41  
  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'),
  49                  );
  50  $hcolumns = array();
  51  
  52  
  53  if (!isset($columns[$sort])) {
  54      $sort = 'lastname';
  55  }
  56  
  57  foreach ($columns as $column=>$strcolumn) {
  58      if ($sort != $column) {
  59          $columnicon = '';
  60          if ($column == 'lastaccess') {
  61              $columndir = 'DESC';
  62          } else {
  63              $columndir = 'ASC';
  64          }
  65      } else {
  66          $columndir = $dir == 'ASC' ? 'DESC':'ASC';
  67          if ($column == 'lastaccess') {
  68              $columnicon = $dir == 'ASC' ? 'up':'down';
  69          } else {
  70              $columnicon = $dir == 'ASC' ? 'down':'up';
  71          }
  72          $columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
  73  
  74      }
  75      $hcolumns[$column] = "<a href=\"index.php?sort=$column&amp;dir=$columndir&amp;page=$page&amp;perpage=$perpage\">".$strcolumn."</a>$columnicon";
  76  }
  77  
  78  $baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
  79  echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
  80  
  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'];
  91  }
  92  
  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();
  99  
 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;
 105  } else {
 106      $orderby = "cl.$sort $dir";
 107  }
 108  
 109  $ufields = user_picture::fields('u');
 110  $sql = "SELECT $ufields,
 111                 cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue
 112            FROM {config_log} cl
 113            JOIN {user} u ON u.id = cl.userid
 114        ORDER BY $orderby";
 115  
 116  $rs = $DB->get_recordset_sql($sql, array(), $page*$perpage, $perpage);
 117  foreach ($rs as $log) {
 118      $row = array();
 119      $row[] = userdate($log->timemodified);
 120      $row[] = fullname($log);
 121      if (is_null($log->plugin)) {
 122          $row[] = 'core';
 123      } else {
 124          $row[] = $log->plugin;
 125      }
 126      $row[] = $log->name;
 127      $row[] = s($log->value);
 128      $row[] = s($log->oldvalue);
 129  
 130      $table->data[] = $row;
 131  }
 132  $rs->close();
 133  
 134  echo html_writer::table($table);
 135  
 136  echo $OUTPUT->footer();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1