From f6523225a3c842cf101e32fbdf6dfc5f3d27f34d Mon Sep 17 00:00:00 2001 From: willtp87 Date: Mon, 8 Dec 2014 11:01:31 -0400 Subject: [PATCH 1/2] Can have non-defined DSs again. --- includes/add_datastream.form.inc | 3 ++- includes/mimetype.utils.inc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/add_datastream.form.inc b/includes/add_datastream.form.inc index 40e1537d..4484a903 100644 --- a/includes/add_datastream.form.inc +++ b/includes/add_datastream.form.inc @@ -149,7 +149,8 @@ function islandora_add_datastream_form_validate(array $form, array &$form_state) $form_state['values']['dsid'] ); $file = file_load($form_state['values']['file']); - if ($file) { + // Only validate extensions if mimes defined in ds-composite. + if ($file && $extensions) { $errors = file_validate_extensions($file, implode(' ', $extensions)); if (count($errors) > 0) { form_set_error( diff --git a/includes/mimetype.utils.inc b/includes/mimetype.utils.inc index beb4dfef..312302b2 100644 --- a/includes/mimetype.utils.inc +++ b/includes/mimetype.utils.inc @@ -73,7 +73,7 @@ function islandora_get_extensions_for_mimetype($mimetype) { function islandora_get_extensions_for_datastream(AbstractObject $object, $dsid) { module_load_include('inc', 'islandora', 'includes/utilities'); $datastream_mime_map = islandora_get_datastreams_requirements_from_models($object->models); - $mimes = $datastream_mime_map[$dsid]['mime']; + $mimes = isset($datastream_mime_map[$dsid]) ? $datastream_mime_map[$dsid]['mime'] : array(); if (isset($object[$dsid])) { $current_mime = $object[$dsid]->mimetype; if (!in_array($current_mime, $mimes)) { From fd2214695686c6ba2b5ee1c9812f2486d1535c65 Mon Sep 17 00:00:00 2001 From: willtp87 Date: Mon, 8 Dec 2014 11:13:38 -0400 Subject: [PATCH 2/2] Stripping out duplicate extensions. --- includes/mimetype.utils.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/mimetype.utils.inc b/includes/mimetype.utils.inc index 312302b2..03708f99 100644 --- a/includes/mimetype.utils.inc +++ b/includes/mimetype.utils.inc @@ -84,5 +84,5 @@ function islandora_get_extensions_for_datastream(AbstractObject $object, $dsid) foreach ($mimes as $mime) { $extensions = array_merge($extensions, islandora_get_extensions_for_mimetype($mime)); } - return $extensions; + return array_unique($extensions); }