Merge branch 'wip-MDL-34429-master' of git://github.com/abgreeve/moodle
This commit is contained in:
+18
-15
@@ -531,10 +531,19 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
|
||||
|
||||
function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
|
||||
$modid, $modaction, $groupid) {
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
|
||||
$text = get_string('course')."\t".get_string('time')."\t".get_string('ip_address')."\t".
|
||||
get_string('fullnameuser')."\t".get_string('action')."\t".get_string('info');
|
||||
require_once($CFG->libdir . '/csvlib.class.php');
|
||||
|
||||
$csvexporter = new csv_export_writer('tab');
|
||||
|
||||
$header = array();
|
||||
$header[] = get_string('course');
|
||||
$header[] = get_string('time');
|
||||
$header[] = get_string('ip_address');
|
||||
$header[] = get_string('fullnameuser');
|
||||
$header[] = get_string('action');
|
||||
$header[] = get_string('info');
|
||||
|
||||
if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
|
||||
$modname, $modid, $modaction, $groupid)) {
|
||||
@@ -561,16 +570,10 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
|
||||
|
||||
$strftimedatetime = get_string("strftimedatetime");
|
||||
|
||||
$filename = 'logs_'.userdate(time(),get_string('backupnameformat', 'langconfig'),99,false);
|
||||
$filename .= '.txt';
|
||||
header("Content-Type: application/download\n");
|
||||
header("Content-Disposition: attachment; filename=\"$filename\"");
|
||||
header("Expires: 0");
|
||||
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
|
||||
header("Pragma: public");
|
||||
|
||||
echo get_string('savedat').userdate(time(), $strftimedatetime)."\n";
|
||||
echo $text."\n";
|
||||
$csvexporter->set_filename('logs', '.txt');
|
||||
$title = array(get_string('savedat').userdate(time(), $strftimedatetime));
|
||||
$csvexporter->add_data($title);
|
||||
$csvexporter->add_data($header);
|
||||
|
||||
if (empty($logs['logs'])) {
|
||||
return true;
|
||||
@@ -600,9 +603,9 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
|
||||
$firstField = format_string($courses[$log->course], true, array('context' => $coursecontext));
|
||||
$fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
|
||||
$row = array($firstField, userdate($log->time, $strftimedatetime), $log->ip, $fullname, $log->module.' '.$log->action, $log->info);
|
||||
$text = implode("\t", $row);
|
||||
echo $text." \n";
|
||||
$csvexporter->add_data($row);
|
||||
}
|
||||
$csvexporter->download_file();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user