Browse Source

Merge pull request #699 from mnylc/7.x-ISLANDORA-2153

ISLANDORA-2153: Allow datastreams with no MIME type restrictions to be replaced with any file type
pull/703/head
Mark Jordan 7 years ago committed by GitHub
parent
commit
61d1ea3133
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; $form_state['object'] = $object;
$extensions = islandora_get_extensions_for_datastream($object, $datastream->id); $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); $valid_extensions = implode(' ', $extensions);
}
$upload_size = min((int) ini_get('post_max_size'), (int) ini_get('upload_max_filesize')); $upload_size = min((int) ini_get('post_max_size'), (int) ini_get('upload_max_filesize'));
return array( return array(
'dsid_fieldset' => 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'); module_load_include('inc', 'islandora', 'includes/utilities');
$datastream_mime_map = islandora_get_datastreams_requirements_from_models($object->models); $datastream_mime_map = islandora_get_datastreams_requirements_from_models($object->models);
$mimes = isset($datastream_mime_map[$dsid]) ? $datastream_mime_map[$dsid]['mime'] : array(); $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])) { if (isset($object[$dsid])) {
$current_mime = $object[$dsid]->mimetype; $current_mime = $object[$dsid]->mimetype;
if (!in_array($current_mime, $mimes)) { if (!in_array($current_mime, $mimes)) {

Loading…
Cancel
Save