From: Jean-Michel Vedrine Date: Wed, 22 Aug 2012 13:19:54 +0000 (+0200) Subject: MDL-34738 fix for the problem found during testing : dat files not accepted on some... X-Git-Tag: v2.3.2~41 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=9832fde1c0dc7b18cff4e9357efbefaf18a7d9f6 MDL-34738 fix for the problem found during testing : dat files not accepted on some servers --- diff --git a/question/format/blackboard/format.php b/question/format/blackboard/format.php index 16264898c0a..88e01306dca 100644 --- a/question/format/blackboard/format.php +++ b/question/format/blackboard/format.php @@ -43,6 +43,18 @@ class qformat_blackboard extends qformat_based_on_xml { return true; } + /** + * Check if the given file is capable of being imported by this plugin. + * As {@link file_storage::mimetype()} now uses finfo PHP extension if available, + * the value returned by $file->get_mimetype for a .dat file is not the same on all servers. + * So if the parent method fails we must use mimeinfo on the filename. + * @param stored_file $file the file to check + * @return bool whether this plugin can import the file + */ + public function can_import_file($file) { + return parent::can_import_file($file) || mimeinfo('type', $file->get_filename()) == $this->mime_type(); + } + public function mime_type() { return mimeinfo('type', '.dat'); }