Browse Source

ISLANDORA-2153: Allow datastreams with no MIME type restrictions to be replaced with any file type (#1)

* Return empty if no restriction set, enforce this on the form
pull/699/head
Diego Pino Navarro 7 years ago committed by GitHub
parent
commit
4dba1b26ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      includes/datastream.version.inc
  2. 4
      includes/mimetype.utils.inc

6
includes/datastream.version.inc

@ -283,7 +283,13 @@ function islandora_datastream_version_replace_form($form, &$form_state, Abstract
$form_state['object'] = $object;
$extensions = islandora_get_extensions_for_datastream($object, $datastream->id);
if (empty($extensions)) {
// In case no extensions are returned, don't limit.
$valid_extensions = NULL;
}
else {
$valid_extensions = implode(' ', $extensions);
}
$upload_size = min((int) ini_get('post_max_size'), (int) ini_get('upload_max_filesize'));
return array(
'dsid_fieldset' => array(

4
includes/mimetype.utils.inc

@ -76,6 +76,10 @@ 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 = isset($datastream_mime_map[$dsid]) ? $datastream_mime_map[$dsid]['mime'] : array();
// If no restriction set via DS-COMPOSITE-MODEL return an empty array.
if (empty($mimes)) {
return array();
}
if (isset($object[$dsid])) {
$current_mime = $object[$dsid]->mimetype;
if (!in_array($current_mime, $mimes)) {

Loading…
Cancel
Save