]> git.mjollnir.org Git - moodle.git/commitdiff
flash upgrader MDL-20841 move the send the flashupgrader from filelib.php to pluginfi...
authorjerome mouneyrac <jerome@moodle.com>
Fri, 4 Dec 2009 04:11:01 +0000 (04:11 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Fri, 4 Dec 2009 04:11:01 +0000 (04:11 +0000)
lib/filelib.php
pluginfile.php

index 81dd5c17450cb762147042b615b302cec0e0d4ec..f650b692650d311d3836c8e69615571b3befdbd5 100644 (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();
index 17332e1036b61ae296a5f1d12a71240c620ecc2d..55e9aa43bfdcfa212a44626196a772a634247883 100644 (file)
@@ -55,8 +55,23 @@ if (!$context = get_context_instance_by_id($contextid)) {
 }
 $fs = get_file_storage();
 
-
-if ($context->contextlevel == CONTEXT_SYSTEM) {
+// 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);
+
+} else if ($context->contextlevel == CONTEXT_SYSTEM) {   
     if ($filearea === 'blog_attachment' || $filearea === 'blog_post') {
 
         if (empty($CFG->bloglevel)) {