Make sure fields in optional groups also becomes optional.

d6
Frode Petterson 2015-01-20 14:48:22 +01:00
parent 8cee9820b0
commit ead790ae1a
1 changed files with 13 additions and 8 deletions

View File

@ -412,13 +412,13 @@ interface H5PFrameworkInterface {
* Start an atomic operation against the dependency storage * Start an atomic operation against the dependency storage
*/ */
public function lockDependencyStorage(); public function lockDependencyStorage();
/** /**
* Stops an atomic operation against the dependency storage * Stops an atomic operation against the dependency storage
*/ */
public function unlockDependencyStorage(); public function unlockDependencyStorage();
/** /**
* Delete a library from database and file system * Delete a library from database and file system
* *
@ -2574,6 +2574,9 @@ class H5PContentValidator {
$found = FALSE; $found = FALSE;
foreach ($semantics->fields as $field) { foreach ($semantics->fields as $field) {
if ($field->name == $key) { if ($field->name == $key) {
if (isset($semantics->optional) && $semantics->optional) {
$field->optional = TRUE;
}
$function = $this->typeMap[$field->type]; $function = $this->typeMap[$field->type];
$found = TRUE; $found = TRUE;
break; break;
@ -2598,11 +2601,13 @@ class H5PContentValidator {
} }
} }
} }
foreach ($semantics->fields as $field) { if (!(isset($semantics->optional) && $semantics->optional)) {
if (!(isset($field->optional) && $field->optional)) { foreach ($semantics->fields as $field) {
// Check if field is in group. if (!(isset($field->optional) && $field->optional)) {
if (! property_exists($group, $field->name)) { // Check if field is in group.
$this->h5pF->setErrorMessage($this->h5pF->t('No value given for mandatory field ' . $field->name)); if (! property_exists($group, $field->name)) {
$this->h5pF->setErrorMessage($this->h5pF->t('No value given for mandatory field ' . $field->name));
}
} }
} }
} }