From 7e55d513a1f661418438a5137eeab89302d98034 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 7 Sep 2008 23:22:23 +0000 Subject: [PATCH] MDL-16072 fixed area browsing --- mod/forum/lib.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 4de09d2427..3c40fa8bd2 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -3993,6 +3993,26 @@ function forum_get_file_areas($course, $cm, $context) { function forum_pluginfile($course, $cminfo, $context, $filearea, $args) { global $CFG, $DB; + if (!$cminfo->uservisible) { + return false; + } + + if ($filearea === 'forum_intro') { + // all users may access it + $relativepath = '/'.implode('/', $args); + $fullpath = $context->id.'forum_intro0'.$relativepath; + + $fs = get_file_storage(); + if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { + return false; + } + + $lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400; + + // finally send the file + send_stored_file($file, $lifetime, 0); + } + $fileareas = array('forum_attachment', 'forum_post'); if (!in_array($filearea, $fileareas)) { return false; -- 2.39.5