|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00026 require(dirname(__FILE__).'/../../config.php'); 00027 require_once($CFG->libdir.'/adminlib.php'); 00028 00029 // page parameters 00030 $page = optional_param('page', 0, PARAM_INT); 00031 $perpage = optional_param('perpage', 30, PARAM_INT); // how many per page 00032 $sort = optional_param('sort', 'timemodified', PARAM_ALPHA); 00033 $dir = optional_param('dir', 'DESC', PARAM_ALPHA); 00034 00035 admin_externalpage_setup('reportconfiglog', '', null, '', array('pagelayout'=>'report')); 00036 echo $OUTPUT->header(); 00037 00038 echo $OUTPUT->heading(get_string('configlog', 'report_configlog')); 00039 00040 $changescount = $DB->count_records('config_log'); 00041 00042 $columns = array('firstname' => get_string('firstname'), 00043 'lastname' => get_string('lastname'), 00044 'timemodified' => get_string('timemodified', 'report_configlog'), 00045 'plugin' => get_string('plugin', 'report_configlog'), 00046 'name' => get_string('setting', 'report_configlog'), 00047 'value' => get_string('value', 'report_configlog'), 00048 'oldvalue' => get_string('oldvalue', 'report_configlog'), 00049 ); 00050 $hcolumns = array(); 00051 00052 00053 if (!isset($columns[$sort])) { 00054 $sort = 'lastname'; 00055 } 00056 00057 foreach ($columns as $column=>$strcolumn) { 00058 if ($sort != $column) { 00059 $columnicon = ''; 00060 if ($column == 'lastaccess') { 00061 $columndir = 'DESC'; 00062 } else { 00063 $columndir = 'ASC'; 00064 } 00065 } else { 00066 $columndir = $dir == 'ASC' ? 'DESC':'ASC'; 00067 if ($column == 'lastaccess') { 00068 $columnicon = $dir == 'ASC' ? 'up':'down'; 00069 } else { 00070 $columnicon = $dir == 'ASC' ? 'down':'up'; 00071 } 00072 $columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />"; 00073 00074 } 00075 $hcolumns[$column] = "<a href=\"index.php?sort=$column&dir=$columndir&page=$page&perpage=$perpage\">".$strcolumn."</a>$columnicon"; 00076 } 00077 00078 $baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage)); 00079 echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl); 00080 00081 $override = new stdClass(); 00082 $override->firstname = 'firstname'; 00083 $override->lastname = 'lastname'; 00084 $fullnamelanguage = get_string('fullnamedisplay', '', $override); 00085 if (($CFG->fullnamedisplay == 'firstname lastname') or 00086 ($CFG->fullnamedisplay == 'firstname') or 00087 ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname' )) { 00088 $fullnamedisplay = $hcolumns['firstname'].' / '.$hcolumns['lastname']; 00089 } else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname') 00090 $fullnamedisplay = $hcolumns['lastname'].' / '.$hcolumns['firstname']; 00091 } 00092 00093 $table = new html_table(); 00094 $table->head = array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']); 00095 $table->align = array('left', 'left', 'left', 'left', 'left', 'left'); 00096 $table->size = array('30%', '10%', '10%', '10%', '20%', '20%'); 00097 $table->width = '95%'; 00098 $table->data = array(); 00099 00100 if ($sort == 'firstname' or $sort == 'lastname') { 00101 $orderby = "u.$sort $dir"; 00102 } else { 00103 $orderby = "cl.$sort $dir"; 00104 } 00105 00106 $ufields = user_picture::fields('u'); 00107 $sql = "SELECT $ufields, 00108 cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue 00109 FROM {config_log} cl 00110 JOIN {user} u ON u.id = cl.userid 00111 ORDER BY $orderby"; 00112 00113 $rs = $DB->get_recordset_sql($sql, array(), $page*$perpage, $perpage); 00114 foreach ($rs as $log) { 00115 $row = array(); 00116 $row[] = userdate($log->timemodified); 00117 $row[] = fullname($log); 00118 if (is_null($log->plugin)) { 00119 $row[] = 'core'; 00120 } else { 00121 $row[] = $log->plugin; 00122 } 00123 $row[] = $log->name; 00124 $row[] = s($log->value); 00125 $row[] = s($log->oldvalue); 00126 00127 $table->data[] = $row; 00128 } 00129 $rs->close(); 00130 00131 echo html_writer::table($table); 00132 00133 echo $OUTPUT->footer();