Skip to content

Commit

Permalink
limit worksheet length to 31 chars on Moodle 1.5: prevents fatal erro…
Browse files Browse the repository at this point in the history
…r lib/excel/workbook.php
  • Loading branch information
gbateson committed Sep 13, 2006
1 parent 666ebd7 commit 5f4a37b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mod/hotpot/report/default.php
Expand Up @@ -625,11 +625,13 @@ function print_excel_report(&$course, &$hotpot, &$tables, &$options) {
// Moodle >= 1.6
require_once("$CFG->libdir/excellib.class.php");
$wb = new MoodleExcelWorkbook("-");
$wsnamelimit = 0; // no limit
} else {
// Moodle <= 1.5
require_once("$CFG->libdir/excel/Worksheet.php");
require_once("$CFG->libdir/excel/Workbook.php");
$wb = new Workbook("-");
$wsnamelimit = 31; // max length in chars
}

// send HTTP headers
Expand All @@ -638,7 +640,16 @@ function print_excel_report(&$course, &$hotpot, &$tables, &$options) {
// create one worksheet for each table
foreach($tables as $table) {
unset($ws);
$ws = &$wb->add_worksheet(empty($table->caption) ? '' : strip_tags($table->caption));
if (empty($table->caption)) {
$wsname = '';
} else {
$wsname = strip_tags($table->caption);
if ($wsnamelimit && strlen($wsname) > $wsnamelimit) {
$wsname = substr($wsname, -$wsnamelimit); // end of string
// $wsname = substr($wsname, 0, $wsnamelimit); // start of string
}
}
$ws = &$wb->add_worksheet($wsname);

$row = 0;
$this->print_excel_head($wb, $ws, $table, $row, $options);
Expand Down

0 comments on commit 5f4a37b

Please sign in to comment.