MDL-62872 atto_recordrtc: max_filesize detection fix

This commit is contained in:
Shamim Rezaie 2019-02-15 18:50:40 +11:00
parent ec819146cc
commit 7dfa238c08
9 changed files with 14 additions and 19 deletions

View file

@ -34,8 +34,6 @@ defined('MOODLE_INTERNAL') || die();
* @param stdClass $fpoptions - unused. * @param stdClass $fpoptions - unused.
*/ */
function atto_recordrtc_params_for_js($elementid, $options, $fpoptions) { function atto_recordrtc_params_for_js($elementid, $options, $fpoptions) {
global $CFG;
$context = $options['context']; $context = $options['context'];
if (!$context) { if (!$context) {
$context = context_system::instance(); $context = context_system::instance();
@ -62,7 +60,10 @@ function atto_recordrtc_params_for_js($elementid, $options, $fpoptions) {
$allowedtypes = ''; $allowedtypes = '';
} }
$maxrecsize = ini_get('upload_max_filesize'); $maxrecsize = get_max_upload_file_size();
if (!empty($options['maxbytes'])) {
$maxrecsize = min($maxrecsize, $options['maxbytes']);
}
$audiortcicon = 'i/audiortc'; $audiortcicon = 'i/audiortc';
$videortcicon = 'i/videortc'; $videortcicon = 'i/videortc';
$params = array('contextid' => $context->id, $params = array('contextid' => $context->id,

View file

@ -346,7 +346,7 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto
}, },
/** /**
* Maximum upload size set on server, in MB. * Maximum upload size set on server, in bytes.
* *
* @attribute maxrecsize * @attribute maxrecsize
* @type String * @type String

View file

@ -346,7 +346,7 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto
}, },
/** /**
* Maximum upload size set on server, in MB. * Maximum upload size set on server, in bytes.
* *
* @attribute maxrecsize * @attribute maxrecsize
* @type String * @type String

View file

@ -543,8 +543,7 @@ M.atto_recordrtc.audiomodule = {
cm.startStopBtn = Y.one('button#start-stop'); cm.startStopBtn = Y.one('button#start-stop');
cm.uploadBtn = Y.one('button#upload'); cm.uploadBtn = Y.one('button#upload');
cm.recType = 'audio'; cm.recType = 'audio';
// Extract the numbers from the string, and convert to bytes. cm.maxUploadSize = scope.get('maxrecsize');
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
// Show alert and close plugin if WebRTC is not supported. // Show alert and close plugin if WebRTC is not supported.
ccm.check_has_gum(); ccm.check_has_gum();
@ -692,8 +691,7 @@ M.atto_recordrtc.videomodule = {
cm.startStopBtn = Y.one('button#start-stop'); cm.startStopBtn = Y.one('button#start-stop');
cm.uploadBtn = Y.one('button#upload'); cm.uploadBtn = Y.one('button#upload');
cm.recType = 'video'; cm.recType = 'video';
// Extract the numbers from the string, and convert to bytes. cm.maxUploadSize = scope.get('maxrecsize');
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
// Show alert and close plugin if WebRTC is not supported. // Show alert and close plugin if WebRTC is not supported.
ccm.check_has_gum(); ccm.check_has_gum();

View file

@ -543,8 +543,7 @@ M.atto_recordrtc.audiomodule = {
cm.startStopBtn = Y.one('button#start-stop'); cm.startStopBtn = Y.one('button#start-stop');
cm.uploadBtn = Y.one('button#upload'); cm.uploadBtn = Y.one('button#upload');
cm.recType = 'audio'; cm.recType = 'audio';
// Extract the numbers from the string, and convert to bytes. cm.maxUploadSize = scope.get('maxrecsize');
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
// Show alert and close plugin if WebRTC is not supported. // Show alert and close plugin if WebRTC is not supported.
ccm.check_has_gum(); ccm.check_has_gum();
@ -692,8 +691,7 @@ M.atto_recordrtc.videomodule = {
cm.startStopBtn = Y.one('button#start-stop'); cm.startStopBtn = Y.one('button#start-stop');
cm.uploadBtn = Y.one('button#upload'); cm.uploadBtn = Y.one('button#upload');
cm.recType = 'video'; cm.recType = 'video';
// Extract the numbers from the string, and convert to bytes. cm.maxUploadSize = scope.get('maxrecsize');
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
// Show alert and close plugin if WebRTC is not supported. // Show alert and close plugin if WebRTC is not supported.
ccm.check_has_gum(); ccm.check_has_gum();

View file

@ -344,7 +344,7 @@ Y.namespace('M.atto_recordrtc').Button = Y.Base.create('button', Y.M.editor_atto
}, },
/** /**
* Maximum upload size set on server, in MB. * Maximum upload size set on server, in bytes.
* *
* @attribute maxrecsize * @attribute maxrecsize
* @type String * @type String

View file

@ -49,8 +49,7 @@ M.atto_recordrtc.audiomodule = {
cm.startStopBtn = Y.one('button#start-stop'); cm.startStopBtn = Y.one('button#start-stop');
cm.uploadBtn = Y.one('button#upload'); cm.uploadBtn = Y.one('button#upload');
cm.recType = 'audio'; cm.recType = 'audio';
// Extract the numbers from the string, and convert to bytes. cm.maxUploadSize = scope.get('maxrecsize');
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
// Show alert and close plugin if WebRTC is not supported. // Show alert and close plugin if WebRTC is not supported.
ccm.check_has_gum(); ccm.check_has_gum();

View file

@ -49,8 +49,7 @@ M.atto_recordrtc.videomodule = {
cm.startStopBtn = Y.one('button#start-stop'); cm.startStopBtn = Y.one('button#start-stop');
cm.uploadBtn = Y.one('button#upload'); cm.uploadBtn = Y.one('button#upload');
cm.recType = 'video'; cm.recType = 'video';
// Extract the numbers from the string, and convert to bytes. cm.maxUploadSize = scope.get('maxrecsize');
cm.maxUploadSize = window.parseInt(scope.get('maxrecsize').match(/\d+/)[0], 10) * Math.pow(1024, 2);
// Show alert and close plugin if WebRTC is not supported. // Show alert and close plugin if WebRTC is not supported.
ccm.check_has_gum(); ccm.check_has_gum();