Skip to content
Snippets Groups Projects
Commit 3bf4773d authored by Frode Petterson's avatar Frode Petterson
Browse files

JI-942 Fix auto content upgrade error handling

parent f408b457
No related branches found
No related tags found
No related merge requests found
Subproject commit 8aba447b3c41186f264fcdab6c849b0d838e7317 Subproject commit f4592119ed547966f90bfecec5b784992a859825
...@@ -200,6 +200,8 @@ $string['nosuchlibrary'] = 'No such library'; ...@@ -200,6 +200,8 @@ $string['nosuchlibrary'] = 'No such library';
$string['noparameters'] = 'No parameters'; $string['noparameters'] = 'No parameters';
$string['invalidparameters'] = 'Invalid Parameters'; $string['invalidparameters'] = 'Invalid Parameters';
$string['missingcontentuserdata'] = 'Error: Could not find content user data'; $string['missingcontentuserdata'] = 'Error: Could not find content user data';
$string['olduploadoldcontent'] = "You're trying to upload content of an older version of H5P. Please upgrade the content on the server it originated from and try to upload again or turn on the H5P Hub to have this server upgrade it for your automaticall.";
$string['anunexpectedsave'] = 'Something unexpected happened. We were unable to save this content.';
$string['maximumgrade'] = 'Maximum grade'; $string['maximumgrade'] = 'Maximum grade';
$string['maximumgradeerror'] = 'Please enter a valid positive integer as the max points available for this activity'; $string['maximumgradeerror'] = 'Please enter a valid positive integer as the max points available for this activity';
......
Subproject commit aa723bcb40bfd1325c918c0f930ad195c63971b2 Subproject commit d1dd47be6f93424c03ecfe6a79c51aa212dbd1ce
...@@ -250,6 +250,15 @@ class mod_hvp_mod_form extends moodleform_mod { ...@@ -250,6 +250,15 @@ class mod_hvp_mod_form extends moodleform_mod {
$messages = array_merge(\mod_hvp\framework::messages('info'), $errors); $messages = array_merge(\mod_hvp\framework::messages('info'), $errors);
$errors['h5pfile'] = implode('<br/>', $messages); $errors['h5pfile'] = implode('<br/>', $messages);
} else {
foreach ($h5pvalidator->h5pC->mainJsonData['preloadedDependencies'] as $dep) {
if ($dep['machineName'] === $h5pvalidator->h5pC->mainJsonData['mainLibrary']) {
if ($h5pvalidator->h5pF->libraryHasUpgrade($dep)) {
// We do not allow storing old content due to security concerns
$errors['h5pfile'] = get_string('olduploadoldcontent', 'hvp');
}
}
}
} }
} }
} }
...@@ -279,6 +288,10 @@ class mod_hvp_mod_form extends moodleform_mod { ...@@ -279,6 +288,10 @@ class mod_hvp_mod_form extends moodleform_mod {
} else { } else {
$data['h5plibrary'] = $library; $data['h5plibrary'] = $library;
if ($core->h5pF->libraryHasUpgrade($library)) {
// We do not allow storing old content due to security concerns
$errors['h5peditor'] = get_string('anunexpectedsave', 'hvp');
} else {
// Verify that parameters are valid. // Verify that parameters are valid.
if (empty($data['h5pparams'])) { if (empty($data['h5pparams'])) {
$errors['h5peditor'] = get_string('noparameters', 'hvp'); $errors['h5peditor'] = get_string('noparameters', 'hvp');
...@@ -293,6 +306,7 @@ class mod_hvp_mod_form extends moodleform_mod { ...@@ -293,6 +306,7 @@ class mod_hvp_mod_form extends moodleform_mod {
} }
} }
} }
}
/** /**
* Validates editor form * Validates editor form
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment