Skip to content

Commit

Permalink
Fix coding warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
icc committed Feb 5, 2019
1 parent 4be695c commit 1d877ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ function hvp_upgrade_2018090300() {
);
}

// Add new libraries fields
// Add new libraries fields.
$table = new xmldb_table('hvp_libraries');
if (!$dbman->field_exists($table, 'add_to')) {
$dbman->add_field($table,
Expand Down
16 changes: 9 additions & 7 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private function validate_upload($data, &$errors) {
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
// We do not allow storing old content due to security concerns.
$errors['h5pfile'] = get_string('olduploadoldcontent', 'hvp');
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ private function validate_created(&$data, &$errors) {
$data['h5plibrary'] = $library;

if ($core->h5pF->libraryHasUpgrade($library)) {
// We do not allow storing old content due to security concerns
// We do not allow storing old content due to security concerns.
$errors['h5peditor'] = get_string('anunexpectedsave', 'hvp');
} else {
// Verify that parameters are valid.
Expand Down Expand Up @@ -353,7 +353,7 @@ public function data_postprocessing($data) {
$core = \mod_hvp\framework::instance();
$data->disable = $core->getStorableDisplayOptions($options, 0);

// Remove metadata wrapper from form data
// Remove metadata wrapper from form data.
$params = json_decode($data->h5pparams);
if ($params !== null) {
$data->params = json_encode($params->params);
Expand All @@ -362,17 +362,19 @@ public function data_postprocessing($data) {
}
}

// Cleanup
// Cleanup.
unset($data->h5pparams);

if ($data->h5paction === 'upload') {
if (empty($data->metadata) || empty($data->metadata->title)) {
// Fix for legacy content upload to work.
// Fetch title from h5p.json or use a default string if not available
// Fetch title from h5p.json or use a default string if not available.
$h5pvalidator = \mod_hvp\framework::instance('validator');
$data->metadata->title = empty($h5pvalidator->h5pC->mainJsonData['title']) ? 'Uploaded Content' : $h5pvalidator->h5pC->mainJsonData['title'];
$data->metadata->title = empty($h5pvalidator->h5pC->mainJsonData['title']) ?
'Uploaded Content' : $h5pvalidator->h5pC->mainJsonData['title'];
}
$data->name = $data->metadata->title; // Sort of a hack, but there is no JavaScript that sets the value when there is no editor...
$data->name = $data->metadata->title; // Sort of a hack,
// but there is no JavaScript that sets the value when there is no editor...
}
}

Expand Down

0 comments on commit 1d877ff

Please sign in to comment.