flash upgrader MDL-20841 move the send the flashupgrader from filelib.php to pluginfile.php

This commit is contained in:
jerome mouneyrac 2009-12-04 04:11:01 +00:00
parent 2367795674
commit 50f9599130
2 changed files with 17 additions and 49 deletions

View File

@ -1452,7 +1452,7 @@ function send_temp_file_finished($path) {
*/
function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='', $dontdie=false) {
global $CFG, $COURSE, $SESSION;
if ($dontdie) {
ignore_user_abort(true);
}
@ -1475,21 +1475,6 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
$mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' :
($mimetype ? $mimetype : mimeinfo('type', $filename));
// If the file is a Flash file and that the user flash player is outdated return a flash upgrader MDL-20841
if (!empty($CFG->excludeoldflashclients) && $mimetype == 'application/x-shockwave-flash'&& !empty($SESSION->flashversion)) {
$userplayerversion = explode('.', $SESSION->flashversion);
$requiredplayerversion = explode('.', $CFG->excludeoldflashclients);
if (($userplayerversion[0] < $requiredplayerversion[0]) ||
($userplayerversion[0] == $requiredplayerversion[0] && $userplayerversion[1] < $requiredplayerversion[1]) ||
($userplayerversion[0] == $requiredplayerversion[0] && $userplayerversion[1] == $requiredplayerversion[1]
&& $userplayerversion[2] < $requiredplayerversion[2])) {
$path = $CFG->dirroot."/lib/flashdetect/flashupgrade.swf"; // Alternate content asking user to upgrade Flash
$filename = "flashupgrade.swf";
$lifetime = 0; // Do not cache
}
}
$lastmodified = $pathisstring ? time() : filemtime($path);
$filesize = $pathisstring ? strlen($path) : filesize($path);
@ -1698,38 +1683,6 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
$isFF = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested
$mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' :
($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
// If the file is a Flash file and that the user flash player is outdated return a flash upgrader MDL-20841
if (!empty($CFG->excludeoldflashclients) && $mimetype == 'application/x-shockwave-flash'&& !empty($SESSION->flashversion)) {
$userplayerversion = explode('.', $SESSION->flashversion);
$requiredplayerversion = explode('.', $CFG->excludeoldflashclients);
if (($userplayerversion[0] < $requiredplayerversion[0]) ||
($userplayerversion[0] == $requiredplayerversion[0] && $userplayerversion[1] < $requiredplayerversion[1]) ||
($userplayerversion[0] == $requiredplayerversion[0] && $userplayerversion[1] == $requiredplayerversion[1]
&& $userplayerversion[2] < $requiredplayerversion[2])) {
$path = $CFG->dirroot."/lib/flashdetect/";
$filename = "flashupgrade.swf";
$entry = new object();
$entry->filearea = 'content';
$entry->contextid = get_system_context()->id;
$entry->filename = $filename;
$entry->filepath = $path;
$entry->timecreated = time();
$entry->timemodified = time();
$entry->mimetype = $mimetype;
$entry->itemid = 0;
$fs = get_file_storage();
$browser = get_file_browser();
$stored_file = $fs->get_file($entry->contextid, $entry->filearea, $entry->itemid, $entry->filepath, $entry->filename);
if (empty($stored_file)) {
$stored_file = $fs->create_file_from_pathname($entry, $path.$filename);
}
$lifetime = 0; // Do not cache
}
}
$lastmodified = $stored_file->get_timemodified();
$filesize = $stored_file->get_filesize();

View File

@ -55,8 +55,23 @@ if (!$context = get_context_instance_by_id($contextid)) {
}
$fs = get_file_storage();
// If the file is a Flash file and that the user flash player is outdated return a flash upgrader MDL-20841
$mimetype = mimeinfo('type', $args[count($args)-1]);
if (!empty($CFG->excludeoldflashclients) && $mimetype == 'application/x-shockwave-flash'&& !empty($SESSION->flashversion)) {
$userplayerversion = explode('.', $SESSION->flashversion);
$requiredplayerversion = explode('.', $CFG->excludeoldflashclients);
$sendflashupgrader = true;
}
if (!empty($sendflashupgrader) && (($userplayerversion[0] < $requiredplayerversion[0]) ||
($userplayerversion[0] == $requiredplayerversion[0] && $userplayerversion[1] < $requiredplayerversion[1]) ||
($userplayerversion[0] == $requiredplayerversion[0] && $userplayerversion[1] == $requiredplayerversion[1]
&& $userplayerversion[2] < $requiredplayerversion[2]))) {
$path = $CFG->dirroot."/lib/flashdetect/flashupgrade.swf"; // Alternate content asking user to upgrade Flash
$filename = "flashupgrade.swf";
$lifetime = 0; // Do not cache
send_file($path, $filename, $lifetime, 0, false, false, $mimetype);
if ($context->contextlevel == CONTEXT_SYSTEM) {
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
if ($filearea === 'blog_attachment' || $filearea === 'blog_post') {
if (empty($CFG->bloglevel)) {