--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This is an empty file which is used in order to prevent
+ * error logs in the serverlog.
+ *
+ * Sometimes developer forgets to postprocess files when saving
+ * submitted form data or forget to replace the file placeholders
+ * with the current area information.
+ *
+ * @package core
+ * @subpackage file
+ * @copyright 2011 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+@header('HTTP/1.0 404 not found');
* @return string if $text was passed in, the rewritten $text is returned. Otherwise NULL.
*/
function file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) {
- global $CFG, $USER;
+ global $CFG, $USER, $CFG;
$options = (array)$options;
if (!isset($options['subdirs'])) {
$fs->create_file_from_storedfile($file_record, $file);
}
}
+ if (!is_null($text)) {
+ // at this point there should not be any draftfile links yet,
+ // because this is a new text from database that should still contain the @@pluginfile@@ links
+ // this happens when developers forget to post process the text
+ $text = str_replace("\"$CFG->httpswwwroot/draftfile.php", "\"$CFG->httpswwwroot/brokenfile.php#", $text);
+ }
} else {
// nothing to do
}
$text = $filtermanager->filter_text($text, $context, array('originalformat' => $format));
break;
}
+ if ($options['filter']) {
+ // at this point there should not be any draftfile links any more,
+ // this happens when developers forget to post process the text.
+ // The only potential problem is that somebody might try to format
+ // the text before storing into database which would be itself big bug.
+ $text = str_replace("\"$CFG->httpswwwroot/draftfile.php", "\"$CFG->httpswwwroot/brokenfile.php#", $text);
+ }
// Warn people that we have removed this old mechanism, just in case they
// were stupid enough to rely on it.