From f1cbbbeb209b4c33aed64e3343c58026f5c8b9de Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Thu, 15 Apr 2010 07:09:28 +0000 Subject: [PATCH] themes MDL-21984 Removed the need to specify the theme name in layouts within its config.php file --- pluginfile.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pluginfile.php b/pluginfile.php index 7e3014eec38..a83f37f1bfa 100644 --- a/pluginfile.php +++ b/pluginfile.php @@ -510,9 +510,26 @@ if (!empty($sendflashupgrader) && (($userplayerversion[0] < $requiredplayervers send_file_not_found(); } else if ($context->contextlevel == CONTEXT_BLOCK) { - //not supported yet - send_file_not_found(); + if (!$context = get_context_instance_by_id($contextid)) { + send_file_not_found(); + } + $birecord = $DB->get_record('block_instances', array('id'=>$context->instanceid), '*',MUST_EXIST); + $blockinstance = block_instance($birecord->blockname, $birecord); + + if (strpos(get_class($blockinstance), $filearea) !== 0) { + send_file_not_found(); + } + + $itemid = array_shift($args); + $filename = array_pop($args); + $filepath = '/'.join('/', $args); + + if (method_exists($blockinstance, 'send_file')) { + $blockinstance->send_file($context, $filearea, $itemid, $filepath, $filename); + } + + send_file_not_found(); } else { send_file_not_found(); -- 2.43.0