Commit ed18319a authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1627545: Skip check for valid json if no file uploaded"

parents 257f72f0 a3080fe2
......@@ -23,6 +23,7 @@ $string['frameworkupdated'] = 'Framework updated';
$string['matrixfile'] = 'Matrix file';
$string['matrixfiledesc'] = 'The .matrix file containing the JSON encoded framework';
$string['notvalidmatrixfile'] = 'This is not a valid .matrix file.';
$string['matrixfilenotfound'] = 'No valid .matrix file selected.';
$string['invalidjson'] = 'This is not a valid .matrix file: Unable to parse the JSON content.';
$string['jsonmissingvars'] = 'This is not a valid .matrix file: Missing "framework" and / or "framework name".';
$string['manuallyremovematrices'] = 'Unable to remove install directory "%s". Please remove it manually.';
......
......@@ -1016,16 +1016,21 @@ function upload_matrix_form() {
function validate_matrixupload(Pieform $form, $values) {
require_once('uploadmanager.php');
if (empty($values['matrix'])) {
$form->set_error('matrix', get_string('matrixfilenotfound', 'module.framework'));
return;
}
$um = new upload_manager('matrix');
if ($error = $um->preprocess_file()) {
$form->set_error('matrix', $error);
return;
}
$reqext = ".matrix";
$fileext = substr($values['matrix']['name'], (-strlen($reqext)));
if ($fileext !== $reqext) {
$form->set_error('matrix', get_string('notvalidmatrixfile', 'module.framework'));
return;
}
$matrixfile = PluginModuleFramework::matrix_is_valid_json($um->file['tmp_name']);
if ($matrixfile['error']) {
$form->set_error('matrix', $matrixfile['message']);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment