admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/category.php');
$PAGE->set_context($context); // Ensure that we are actually showing blocks etc for the cat context
echo $OUTPUT->header();
- } else {
+ } else {
$PAGE->navbar->add($strcategories, new moodle_url('/course/index.php'));
$PAGE->navbar->add($category->name);
$PAGE->navbar->add($strcourses);
if (!isset($category->descriptionformat)) {
$category->descriptionformat = FORMAT_MOODLE;
}
- echo format_text($category->description, $category->descriptionformat, $options);
+ $text = file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'category_description', $category->id);
+ echo format_text($text, $category->descriptionformat, $options);
echo $OUTPUT->box_end();
}
$lifetime = 0; // Do not cache
send_file($path, $filename, $lifetime, 0, false, false, $mimetype);
-} else if ($context->contextlevel == CONTEXT_SYSTEM) {
+} else if ($context->contextlevel == CONTEXT_SYSTEM) {
if ($filearea === 'blog_attachment' || $filearea === 'blog_post') {
if (empty($CFG->bloglevel)) {
} else if ($context->contextlevel == CONTEXT_COURSECAT) {
- if ($filearea !== 'coursecat_intro') {
- send_file_not_found();
- }
+ if ($filearea == 'coursecat_intro') {
+ if ($CFG->forcelogin) {
+ // no login necessary - unless login forced everywhere
+ require_login();
+ }
- if ($CFG->forcelogin) {
- // no login necessary - unless login forced everywhere
- require_login();
- }
+ $relativepath = '/'.implode('/', $args);
+ $fullpath = $context->id.'coursecat_intro0'.$relativepath;
- $relativepath = '/'.implode('/', $args);
- $fullpath = $context->id.'coursecat_intro0'.$relativepath;
+ if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->get_filename() == '.') {
+ send_file_not_found();
+ }
- if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->get_filename() == '.') {
+ session_get_instance()->write_close(); // unlock session during fileserving
+ send_stored_file($file, 60*60, 0, $forcedownload);
+ } else if ($filearea == 'category_description') {
+ if ($CFG->forcelogin) {
+ // no login necessary - unless login forced everywhere
+ require_login();
+ }
+ $itemid = (int)array_shift($args);
+
+ $relativepath = '/'.implode('/', $args);
+ $fullpath = $context->id.'category_description'.$itemid.$relativepath;
+
+ if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->get_filename() == '.') {
+ send_file_not_found();
+ }
+
+ session_get_instance()->write_close(); // unlock session during fileserving
+ send_stored_file($file, 60*60, 0, $forcedownload);
+ } else {
send_file_not_found();
}
- session_get_instance()->write_close(); // unlock session during fileserving
- send_stored_file($file, 60*60, 0, $forcedownload);
-
} else if ($context->contextlevel == CONTEXT_COURSE) {
if (!$course = $DB->get_record('course', array('id'=>$context->instanceid))) {
session_get_instance()->write_close();
send_stored_file($file, 60*60, 0, false);
-
+
} else if ($filearea === 'user_profile') {
$userid = (int)array_shift($args);
$usercontext = get_context_instance(CONTEXT_USER, $userid);
-
+
if ($CFG->forcelogin) {
require_login();
}