Skip to content

Commit

Permalink
MDL-16072 fixed area browsing
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 7, 2008
1 parent 3445b38 commit 7e55d51
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mod/forum/lib.php
Expand Up @@ -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;
Expand Down

0 comments on commit 7e55d51

Please sign in to comment.