]> git.mjollnir.org Git - moodle.git/commitdiff
Added an option on the filters page to control whether uploaded
authormoodler <moodler>
Thu, 11 Mar 2004 02:14:15 +0000 (02:14 +0000)
committermoodler <moodler>
Thu, 11 Mar 2004 02:14:15 +0000 (02:14 +0000)
files are parsed by filters.    bug 1128

admin/filters.html
admin/filters.php
file.php
lang/en/admin.php
lang/en/moodle.php
lib/defaults.php

index f98fe2498c6f48d0bf02eeb976dd7f7489866859..5f7f10fe5a13d0acd9f25d251fa79251ffec2941 100644 (file)
        <?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>
index 45373087b947af9b3d8feba64e13a8a5bfebd4e5..abb3b5df2aa3ff992dc2fbf95f95bd7368d343d0 100644 (file)
@@ -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> -> ".
index 42973de01d453561f0c1326eaca46760fc3f281d..3c4e0da045a4d259b63caeff735007d40abe2d61 100644 (file)
--- a/file.php
+++ b/file.php
         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");
index fc8489e9d9c5fddc6544b0fb5caa4ebd5dc1e2b1..a7fff473ee722cac21d20a5404d5345736ff4be8 100755 (executable)
@@ -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?';
 
index 8da1d0f7cf66aa24e7c4652ff59ca6808e13fbb6..d6b4cebaef73807ed1a0f88bacdc4be9cea5e613 100644 (file)
@@ -131,6 +131,7 @@ $string['configcachetext'] = 'For larger sites or sites that use text filters, t
 $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).';
index c6a579cd899471671d626eee1c176507a574852f..cb581f24f14409664c1c98f3fd61df552dd08745 100644 (file)
@@ -10,6 +10,7 @@
        "changepassword"   =>  true,
        "country"          => "",
        "debug"            =>  7,
+       "filteruploadedfiles"  =>  true,
        "forcelogin"       =>  false,
        "fullnamedisplay"  => "firstname lastname",
        "framename"        => "_top",