Skip to content

Commit

Permalink
Added an option on the filters page to control whether uploaded
Browse files Browse the repository at this point in the history
files are parsed by filters.    bug 1128
  • Loading branch information
moodler committed Mar 11, 2004
1 parent d64f600 commit 3cf4ab9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
15 changes: 15 additions & 0 deletions admin/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@
<?php p($strconfigcachetext) ?>
</td>
</tr>
<tr valign=top>
<td nowrap="nowrap" align="right"><?php p($strfilteruploadedfiles) ?>:</td>
<td>
<?php
unset($options);
$options[0] = get_string('no');
$options[1] = get_string('yes');

choose_from_menu ($options, "filteruploadedfiles", $CFG->filteruploadedfiles, "", "", "");
?>
</td>
<td>
<?php p($strconfigfilteruploadedfiles) ?>
</td>
</tr>
<tr valign=top>
<td>&nbsp;</td>
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
Expand Down
2 changes: 2 additions & 0 deletions admin/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
$strinactive = get_string("inactive");
$strcachetext = get_string("cachetext", "admin");
$strconfigcachetext = get_string("configcachetext");
$strfilteruploadedfiles = get_string("filteruploadedfiles", "admin");
$strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles");

print_header("$site->shortname: $strmanagefilters", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ".
Expand Down
30 changes: 18 additions & 12 deletions file.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,26 @@
header("Content-length: ".filesize($pathname));


if ($mimetype == "text/html") {
header("Content-type: text/html");
echo format_text(implode('', file($pathname)), FORMAT_HTML, NULL, $courseid); // Filter HTML files

} else if ($mimetype == "text/plain") {
header("Content-type: text/html");
$options->newlines = false;
echo "<pre>";
echo format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid); // Filter TEXT files
echo "</pre>";

} else {
if (empty($CFG->filteruploadedfiles)) {
header("Content-type: $mimetype");
readfile($pathname);

} else { /// Try and put the file through filters
if ($mimetype == "text/html") {
header("Content-type: text/html");
echo format_text(implode('', file($pathname)), FORMAT_HTML, NULL, $courseid);

} else if ($mimetype == "text/plain") {
header("Content-type: text/html");
$options->newlines = false;
echo "<pre>";
echo format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid);
echo "</pre>";

} else { /// Just send it out raw
header("Content-type: $mimetype");
readfile($pathname);
}
}
} else {
error("Sorry, but the file you are looking for was not found ($pathname)", "course/view.php?id=$courseid");
Expand Down
1 change: 1 addition & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


$string['cachetext'] = 'Text cache lifetime';
$string['filteruploadedfiles'] = 'Filter uploaded files';
$string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. <a href=\"$a\">More information</a>';
$string['upgradelogsinfo'] = 'Some changes have way some logs are stored. To be able to view all of your old logs on a per-activity basis, your old logs need to be upgraded. Depending on your site this can take a long time (eg several hours) and can be quite taxing on the database for large sites. Once you start this process you should let it finish (by keeping the browser window open). Don\'t worry - your site will work fine for other people while the logs are being upgraded.<br /><br />Do you want to upgrade your logs now?';

Expand Down
1 change: 1 addition & 0 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
$string['configcountry'] = 'If you set a country here, then this country will be selected by default on new user accounts. To force users to choose a country, just leave this unset.';
$string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed. This is only useful for developers.';
$string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice.';
$string['configfilteruploadedfiles'] = 'Enabling this setting will cause Moodle to process all uploaded HTML and text files with the filters before displaying them.';
$string['configforcelogin'] = 'Normally, the front page of the site and the course listings (but not courses) can be read by people without logging in to the site. If you want to force people to log in before they do ANYTHING on the site, then you should enable this setting.';
$string['configframename'] = 'If you are embedding Moodle within a web frame, then put the name of this frame here. Otherwise this value should remain as \'_top\'';
$string['configfullnamedisplay'] = 'This defines how names are shown when they are displayed in full. For most mono-lingual sites the most efficient setting is the default \"Given names + Surname\", but you may choose to hide surnames altogether, or to leave it up to the current language pack to decide (some languages have different conventions).';
Expand Down
1 change: 1 addition & 0 deletions lib/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"changepassword" => true,
"country" => "",
"debug" => 7,
"filteruploadedfiles" => true,
"forcelogin" => false,
"fullnamedisplay" => "firstname lastname",
"framename" => "_top",
Expand Down

0 comments on commit 3cf4ab9

Please sign in to comment.