Browse Source

Merge pull request #6 from Islandora/7.x

update 7.x
pull/507/head
qadan 11 years ago
parent
commit
8431310f8f
  1. 100
      README.md
  2. 12
      includes/admin.form.inc
  3. 103
      includes/datastream.version.inc
  4. 35
      includes/mime_detect.inc
  5. 47
      includes/utilities.inc
  6. 53
      islandora.api.php
  7. 1
      islandora.info
  8. 5
      islandora.install
  9. 36
      islandora.module
  10. 31
      policies/permit-apim-to-anonymous-user.xml
  11. 31
      policies/permit-apim-to-authenticated-user.xml
  12. 25
      policies/permit-getDatastream-unrestricted.xml
  13. 25
      policies/permit-getDatastreamHistory-unrestricted.xml
  14. 31
      policies/permit-upload-to-anonymous-user.xml
  15. 31
      policies/permit-upload-to-authenticated-user.xml
  16. 2
      tests/islandora_hooked_access_test.module
  17. 83
      tests/islandora_manage_temp_file.test
  18. 2
      tests/scripts/travis_setup.sh
  19. 30
      theme/theme.inc

100
README.md

@ -1,86 +1,70 @@
BUILD STATUS
------------
Current build status:
[![Build Status](https://travis-ci.org/Islandora/islandora.png?branch=7.x)](https://travis-ci.org/Islandora/islandora)
# Islandora [![Build Status](https://travis-ci.org/Islandora/islandora.png?branch=7.x)](https://travis-ci.org/Islandora/islandora)
CI Server:
http://jenkins.discoverygarden.ca
SUMMARY
-------
## Introduction
Islandora Fedora Repository Module
For installation and customization instructions please see the documentation
and the DuraSpace Wiki:
For installation and customization instructions please see the [documentation and the DuraSpace Wiki](https://wiki.duraspace.org/display/ISLANDORA/Islandora).
All bugs, feature requests and improvement suggestions are tracked at the [DuraSpace JIRA](https://jira.duraspace.org/browse/ISLANDORA).
## Requirements
This module requires the following modules/libraries:
https://wiki.duraspace.org/display/ISLANDORA/Islandora
* [Tuque](https://github.com/islandora/tuque)
All bugs, feature requests and improvement suggestions are tracked at the
DuraSpace JIRA:
Tuque is expected to be in one of two paths:
https://jira.duraspace.org/browse/ISLANDORA
* sites/all/libraries/tuque (libraries directory may need to be created)
* islandora_folder/libraries/tuque
REQUIREMENTS
------------
The Tuque library must be installed to use Islandora. It can be found here:
http://github.com/Islandora/tuque
It is expected to be in one of two paths:
- sites/all/libraries/tuque (libraries directory may need to be created)
- islandora_folder/libraries/tuque
More detailed requirements are outlined in the [Installing the Islandora Module](https://wiki.duraspace.org/display/ISLANDORA712/Installing+the+Islandora+Module) chapter of the documentation.
OPTIONAL REQUIREMENTS
---------------------
### Optional Requirements
If you want to support languages other than English download and enable
[String Translation](https://drupal.org/project/i18n), And follow our
[guide](wiki/Multilingual-Support) for setting up additional languges.
If you want to support languages other than English download and enable [String Translation](https://drupal.org/project/i18n), and follow our [guide](wiki/Multilingual-Support) for setting up additional languges.
## Installation
INSTALLATION
------------
Before installing Islandora the XACML policies located [here](https://github.com/Islandora/islandora-xacml-policies) should be copied into the Fedora global XACML policies folder. This will allow "authenticated users" in Drupal to access Fedora API-M functions. It is to be noted that the `permit-upload-to-anonymous-user.xml` and `permit-apim-to-anonymous-user.xml` files do not need to be present unless requirements for anonymous ingesting are present.
Before installing Islandora the XACML policies located in the policies folder
should be copied into the Fedora global XACML policies folder. This will allow
"authenticated users" in Drupal to access Fedora API-M functions. It is to be
noted that the permit-upload-to-anonymous-user.xml and
permit-apim-to-anonymous-user.xml files do not need to be present unless
requirements for anonymous ingesting are present.
You will also have to remove some default policies if you want full functionality as well.
You will also have to remove some default policies if you want full
functionality as well.
Remove deny-purge-datastream-if-active-or-inactive.xml to allow for purging of datastream versions.
Remove deny-purge-datastream-if-active-or-inactive.xml to allow for purging of
datastream versions.
More detailed information can be found in the 'Set XACML Policies' in the [Installing Fedora](https://wiki.duraspace.org/display/ISLANDORA713/Installing+Fedora) chapter of the documentation.
CONFIGURATION
-------------
## Configuration
The islandora_drupal_filter passes the username of 'anonymous' through to
Fedora for unauthenticated Drupal Users. A user with the name of 'anonymous'
may have XACML policies applied to them that are meant to be applied to Drupal
users that are not logged in or vice-versa. This is a potential security issue
that can be plugged by creating a user named 'anonymous' and restricting access
to the account.
The islandora_drupal_filter passes the username of 'anonymous' through to Fedora for unauthenticated Drupal Users. A user with the name of 'anonymous' may have XACML policies applied to them that are meant to be applied to Drupal users that are not logged in or vice-versa. This is a potential security issue that can be plugged by creating a user named 'anonymous' and restricting access to the account.
Drupal's cron will can be ran to remove expired authentication tokens.
Drupal's cron can be run to remove expired authentication tokens.
CUSTOMIZATION
-------------
### Customization
[Customize ingest forms](http://github.com/Islandora/islandora/wiki/Multi-paged-Ingest-Forms)
TROUBLESHOOTING
---------------
## Troubleshooting/Issues
Having problems or solved a problem? Check out the Islandora google groups for a solution.
* [Islandora Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora)
* [Islandora Dev Group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/islandora-dev)
## Maintainers/Sponsors
Current maintainers:
* [Nick Ruest](https://github.com/ruebot)
F.A.Q.
------
## Development
If you would like to contribute to this module, please check out our helpful [Documentation for Developers](https://github.com/Islandora/islandora/wiki#wiki-documentation-for-developers) info, as well as our [Developers](http://islandora.ca/developers) section on the Islandora.ca site.
The tests for this module will not run through Drupal’s UI. They will work using Drush, which works around Drupal’s batch API.
CONTACT
-------
## License
[GPLv3](http://www.gnu.org/licenses/gpl-3.0.txt)
SPONSORS
--------

12
includes/admin.form.inc

@ -72,7 +72,7 @@ function islandora_repository_admin(array $form, array &$form_state) {
'#default_value' => $restrict_namespaces,
),
'islandora_pids_allowed' => array(
'#type' => 'textfield',
'#type' => 'textarea',
'#title' => t('PID namespaces allowed in this Drupal install'),
'#description' => t('A list of PID namespaces, separated by spaces, that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace, e.g. <b>demo:mydemos</b>. <br /> The namespace <b>islandora:</b> is reserved, and is always allowed.'),
'#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '),
@ -83,6 +83,16 @@ function islandora_repository_admin(array $form, array &$form_state) {
),
),
),
'islandora_ds_replace_exclude' => array(
'#type' => 'fieldset',
'#title' => t('Excluded DSID'),
'islandora_ds_replace_exclude_enforced' => array(
'#type' => 'textfield',
'#title' => t('Enforce DSID restrictions'),
'#description' => t("A comma seperated list, allowing administrator to restrict user's access to replace a versionable datastreams latest version"),
'#default_value' => variable_get('islandora_ds_replace_exclude_enforced', 'RELS-EXT,RELS-INT'),
),
),
),
);
return system_settings_form($form);

103
includes/datastream.version.inc

@ -231,6 +231,109 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo
$form_state['redirect'] = "islandora/object/{$islandora_object->id}/datastream/{$datastream_to_revert->id}/version";
}
/**
* The admin replace datastream form.
*
* @param array $form
* The Drupal form.
* @param array $form_state
* The Drupal form state.
* @param AbstractDatastream $datastream
* The datastream to be updated.
*
* @return array
* The drupal form definition.
*/
function islandora_datastream_version_replace_form($form, &$form_state, AbstractDatastream $datastream) {
module_load_include('inc', 'islandora', 'includes/content_model');
module_load_include('inc', 'islandora', 'includes/utilities');
$object = islandora_object_load($datastream->parent->id);
$form_state['object_id'] = $object->id;
$form_state['dsid'] = $datastream->id;
$form_state['object'] = $object;
$extensions = islandora_get_datastreams_requirements_from_models($object->models);
$mime_detect = new MimeDetect();
$ext = array();
foreach ($extensions[$datastream->id]['mime'] as $key => $value) {
$str = $mime_detect->getExtension($value);
array_push($ext, $str);
}
$comma = count($ext) > 1 ? "," : "";
$ext = array(implode($comma, $ext));
$upload_size = min((int) ini_get('post_max_size'), (int) ini_get('upload_max_filesize'));
return array(
'dsid_fieldset' => array(
'#type' => 'fieldset',
'#title' => t("Update datastream with latest version"),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'dsid' => array(
'#type' => 'markup',
'#markup' => "<div>DSID: <b>$datastream->id</b></div>",
),
'label' => array(
'#type' => 'markup',
'#markup' => "<div>Label: <b>$datastream->label</b></div>",
),
'file' => array(
'#type' => 'managed_file',
'#required' => TRUE,
'#title' => t('Upload Document'),
'#size' => 64,
'#description' => t('Select a file to upload.<br/>Files must be less than <strong>@size MB.</strong>', array('@size' => $upload_size)),
'#upload_location' => 'temporary://',
'#upload_validators' => array(
'file_validate_extensions' => $ext,
// Assume its specified in MB.
'file_validate_size' => array($upload_size * 1024 * 1024),
),
),
'submit' => array(
'#type' => 'submit',
'#value' => t('Add Contents'),
),
),
);
}
/**
* Submit handler for the replace datastream form.
*
* Adds a new datastream version as latest.
*
* @param array $form
* The Drupal form.
* @param array $form_state
* The Drupal form state.
*/
function islandora_datastream_version_replace_form_submit($form, &$form_state) {
$object = islandora_object_load($form_state['object_id']);
$form_state['redirect'] = "islandora/object/{$object->id}";
$file = file_load($form_state['values']['file']);
try {
$ds = $object[$form_state['dsid']];
$ds->mimetype = $file->filemime;
$path = drupal_realpath($file->uri);
$ds->setContentFromFile($path);
file_delete($file);
}
catch (exception $e) {
drupal_set_message(t('An error occurred during datastream updates. See watchlog for more information.'), 'error');
watchdog('islandora',
'Failed to add new versionable datastream.<br/>code: @code<br/>message: @msg',
array(
'@code' => $e->getCode(),
'@msg' => $e->getMessage(),
),
WATCHDOG_ERROR
);
file_delete($file);
return;
}
drupal_set_message(t("Successfully Updated Datastream"));
}
/**
* Gets Audit datastream values from foxml.
*

35
includes/mime_detect.inc

@ -184,6 +184,41 @@ class MimeDetect {
"ogg" => "audio/ogg",
"flac" => "audio/x-flac",
"wav" => "audio/vnd.wave",
// Chemical:
// MDL Molfile.
"mol" => "chemical/x-mdl-molfile",
// XYZ format.
"xyz" => "chemical/x-xyz",
// PDB.
"pdb" => "chemical/x-pdb",
// ChemDraw 3D.
"c3d" => "chemical/x-chem3d",
// ChemDraw file.
"chm" => "chemical/x-chemdraw",
// Crystallographic Information File.
"cif" => "chemical/x-cif",
// Chemical Markup Language.
"cml" => "chemical/x-cml",
// GAMESS Input.
"inp" => "chemical/x-gamess-input",
// GAMESS Output.
"gam" => "chemical/x-gamess-input",
// General output file.
"out" => "application/octet-stream",
// Gaussian Cube.
"cub" => "chemical/x-gaussian-cube",
// Gaussian 98/03 Cartesian Input.
"gau" => "chemical/x-gaussian-input",
// Corel Multimedia Manager v6 Album.
"gal" => "application/octet-stream",
// JCAMP Spectroscopic Data Exchange Format.
"jdx" => "chemical/x-jcamp-dx",
// OpenDX Grid.
"dx" => "chemical/x-jcamp-dx",
// MOPAC Cartesian.
"mop" => "chemical/x-mopac-input",
// General Input File.
"in" => "application/octet-stream",
// Compressed formats:
// (note: http://svn.cleancode.org/svn/email/trunk/mime.types)
"tgz" => "application/x-gzip",

47
includes/utilities.inc

@ -46,6 +46,37 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) {
}
}
/**
* Add a file as managed if is not already.
*
* @param string $file_uri
* The given file URI location.
*
* @return object
* The file, as returned from file_save().
*/
function islandora_temp_file_entry($file_uri, $mime = NULL) {
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'file')
->propertyCondition('uri', $file_uri)
->execute();
if (isset($result['file'])) {
$fid = current($result['file'])->fid;
$file = file_load($fid);
}
else {
$file = new stdClass();
$file->uri = $file_uri;
$file->filename = drupal_basename($file_uri);
if (isset($mime)) {
$file->filemime = $mime;
}
}
$file->status = 0;
return file_save($file);
}
/**
* Creates a label for control group symbols.
*/
@ -486,10 +517,12 @@ function islandora_prepare_new_object($namespace = NULL, $label = NULL, $datastr
// set datastream_file by url for the given scheme. Https (SSL) can
// cause this to fail, and trigger an output log in watchdog.
$datastream_file = url($ds['datastream_file'], array('absolute' => TRUE));
watchdog('islandora',
'Attempting to ingest %file in islandora_prepare_new_object(), but it does not appear to be readable. We will pass the path through url(), and pass along as such.',
array('%file' => $datastream_file),
WATCHDOG_WARNING);
watchdog(
'islandora',
'Attempting to ingest %file in islandora_prepare_new_object(), but it does not appear to be readable. We will pass the path through url(), and pass along as such.',
array('%file' => $datastream_file),
WATCHDOG_WARNING
);
}
}
@ -859,9 +892,9 @@ function islandora_deprecated($release, $solution = NULL) {
assert($bt[0]['function'] == __FUNCTION__);
$function = $bt[1]['function'];
$message = t('@function() has been deprecated. As of @release, please update your code before the next release.', array(
'@function' => $function,
'@release' => $release,
));
'@function' => $function,
'@release' => $release,
));
if (isset($solution)) {
$message .= "<br/>\n" . $solution;
}

53
islandora.api.php

@ -57,7 +57,7 @@ function hook_islandora_view_print_object($object) {
* @return array
* An array whose values are markup.
*/
function hook_CMODEL_PID_islandora_view_object($object) {
function hook_cmodel_pid_islandora_view_object($object) {
}
@ -82,7 +82,7 @@ function hook_islandora_view_object_alter(&$object, &$rendered) {
* @param array $rendered
* The array of rendered views.
*/
function hook_CMODEL_PID_islandora_view_object_alter(&$object, &$rendered) {
function hook_cmodel_pid_islandora_view_object_alter(&$object, &$rendered) {
}
/**
@ -109,7 +109,7 @@ function hook_islandora_edit_object($object) {
* @return array
* An array whose values are markup.
*/
function hook_CMODEL_PID_islandora_edit_object($object) {
function hook_cmodel_pid_islandora_edit_object($object) {
}
/**
@ -160,7 +160,7 @@ function hook_islandora_object_alter(AbstractObject $object, array &$context) {
*
* @see hook_islandora_object_alter()
*/
function hook_CMODEL_PID_islandora_object_alter(AbstractObject $object, array &$context) {
function hook_cmodel_pid_islandora_object_alter(AbstractObject $object, array &$context) {
}
/**
@ -209,7 +209,7 @@ function hook_islandora_datastream_alter(AbstractObject $object, AbstractDatastr
*
* @see hook_islandora_datastream_alter()
*/
function hook_CMODEL_PID_DSID_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
function hook_cmodel_pid_dsid_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
}
/**
@ -233,7 +233,7 @@ function hook_islandora_object_ingested(AbstractObject $object) {
*
* @see hook_islandora_object_ingested()
*/
function hook_CMODEL_PID_islandora_object_ingested(AbstractObject $object) {
function hook_cmodel_pid_islandora_object_ingested(AbstractObject $object) {
}
/**
@ -258,7 +258,7 @@ function hook_islandora_object_modified(AbstractObject $object) {
*
* @see hook_islandora_object_modified()
*/
function hook_CMODEL_PID_islandora_object_modified(AbstractObject $object) {
function hook_cmodel_pid_islandora_object_modified(AbstractObject $object) {
}
/**
@ -278,7 +278,7 @@ function hook_islandora_object_purged($pid) {
*
* @see hook_islandora_object_purged()
*/
function hook_CMODEL_PID_islandora_object_purged($pid) {
function hook_cmodel_pid_islandora_object_purged($pid) {
}
/**
@ -303,7 +303,7 @@ function hook_islandora_datastream_ingested(AbstractObject $object, AbstractData
*
* @see hook_islandora_object_ingested()
*/
function hook_CMODEL_PID_DSID_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
function hook_cmodel_pid_dsid_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
}
/**
@ -330,7 +330,7 @@ function hook_islandora_datastream_modified(AbstractObject $object, AbstractData
*
* @see hook_islandora_datastream_modified()
*/
function hook_CMODEL_PID_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) {
function hook_cmodel_pid_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) {
}
/**
@ -352,7 +352,7 @@ function hook_islandora_datastream_purged(AbstractObject $object, $dsid) {
*
* @see hook_islandora_datastream_purged()
*/
function hook_CMODEL_PID_islandora_datastream_purged(AbstractObject $object, $dsid) {
function hook_cmodel_pid_islandora_datastream_purged(AbstractObject $object, $dsid) {
}
/**
@ -489,11 +489,11 @@ function hook_islandora_ingest_steps_alter(array &$steps, array &$form_state) {
*
* @see hook_islandora_ingest_steps()
*/
function hook_CMODEL_PID_islandora_ingest_steps(array $form_state) {
function hook_cmodel_pid_islandora_ingest_steps(array $form_state) {
}
/**
* Alter the generated ingest steps for the given content model.
* Alter the generated ingest steps for the given content model.
*
* @param array $steps
* An array of steps as generated by hook_islandora_ingest_steps().
@ -501,7 +501,7 @@ function hook_CMODEL_PID_islandora_ingest_steps(array $form_state) {
* @param array $form_state
* An array containing the Drupal form_state.
*/
function hook_CMODEL_PID_islandora_ingest_steps_alter(array &$steps, array &$form_state) {
function hook_cmodel_pid_islandora_ingest_steps_alter(array &$steps, array &$form_state) {
}
/**
@ -540,7 +540,7 @@ function hook_islandora_object_access($op, $object, $user) {
*
* @see hook_islandora_object_access()
*/
function hook_CMODEL_PID_islandora_object_access($op, $object, $user) {
function hook_cmodel_pid_islandora_object_access($op, $object, $user) {
}
/**
@ -579,7 +579,7 @@ function hook_islandora_datastream_access($op, $object, $user) {
*
* @see hook_islandora_datastream_access()
*/
function hook_CMODEL_PID_islandora_datastream_access($op, $object, $user) {
function hook_cmodel_pid_islandora_datastream_access($op, $object, $user) {
}
/**
@ -594,7 +594,7 @@ function hook_islandora_overview_object(AbstractObject $object) {
*
* Content model specific.
*/
function hook_CMODEL_PID_islandora_overview_object(AbstractObject $object) {
function hook_cmodel_pid_islandora_overview_object(AbstractObject $object) {
return drupal_render(drupal_get_form('some_form', $object));
}
/**
@ -609,17 +609,19 @@ function hook_islandora_overview_object_alter(AbstractObject &$object, &$output)
*
* Content model specific.
*/
function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object, &$output) {
function hook_cmodel_pid_islandora_overview_object_alter(AbstractObject &$object, &$output) {
$output = $output . drupal_render(drupal_get_form('some_form', $object));
}
/*
/**
* Defines derivative functions to be executed based on certain conditions.
*
* @param AbstractObject $object
* Object to which derivatives will be added
* This hook fires when an object/datastream is ingested or a datastream is
* modified.
* modified. It may also be called to discover the datastream derivative
* hierarchy.
*
* @param AbstractObject $object
* Optional object to which derivatives will be added
*
* @return array
* An array containing an entry for each derivative to be created. Each entry
@ -653,7 +655,7 @@ function hook_CMODEL_PID_islandora_overview_object_alter(AbstractObject &$object
* - file: A string denoting the path to the file where the function
* is being called from.
*/
function hook_islandora_derivative(AbstractObject $object) {
function hook_islandora_derivative(AbstractObject $object = NULL) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
@ -692,12 +694,11 @@ function hook_islandora_derivative(AbstractObject $object) {
*
* @see hook_islandora_derivative()
*/
function hook_CMODEL_PID_islandora_derivative() {
function hook_cmodel_pid_islandora_derivative() {
}
/**
* Retrieves PIDS of related objects for property updating.
*
* @param AbstractObject $object
@ -743,7 +744,7 @@ function hook_islandora_breadcrumbs_alter(&$breadcrumbs, $context, $object = NUL
* wishes to default back to the Dublin Core display for the current object.
* -configuration (Optional): A path to the administration page for the
* metadata display.
*
* @see islandora_retrieve_metadata_markup()
*/
function hook_islandora_metadata_display_info() {

1
islandora.info

@ -22,5 +22,6 @@ files[] = tests/islandora_manage_permissions.test
files[] = tests/datastream_versions.test
files[] = tests/datastream_cache.test
files[] = tests/derivatives.test
files[] = tests/islandora_manage_temp_file.test
files[] = tests/datastream_validator_tests.test
php = 5.3

5
islandora.install

@ -43,6 +43,11 @@ function islandora_install() {
function islandora_uninstall() {
module_load_include('inc', 'islandora', 'includes/solution_packs');
islandora_install_solution_pack('islandora', 'uninstall');
// Add new variables to clean up.
$variables = array(
'islandora_ds_replace_exclude_enforced',
);
array_walk($variables, 'variable_del');
}
/**

36
islandora.module

@ -37,7 +37,7 @@ define('ISLANDORA_VIEW_DATASTREAM_HISTORY', 'view old datastream versions');
define('ISLANDORA_MANAGE_DELETED_OBJECTS', 'manage deleted objects');
define('ISLANDORA_REVERT_DATASTREAM', 'revert to old datastream');
define('ISLANDORA_REGENERATE_DERIVATIVES', 'regenerate derivatives for an object');
define('ISLANDORA_REPLACE_DATASTREAM_CONTENT', 'replace a datastream with new content, preserving version history');
// Hooks.
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
@ -64,19 +64,6 @@ define('ISLANDORA_DERVIATIVE_CREATION_HOOK', 'islandora_derivative');
define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models');
define('ISLANDORA_MIME_TYPES_AUTOCOMPLETE', 'islandora/autocomplete/mime-types');
/**
* @deprecated Constants.
*/
// @codingStandardsIgnoreStart
define('DS_COMP_STREAM', ISLANDORA_DS_COMP_STREAM);
define('FEDORA_VIEW_OBJECTS', ISLANDORA_VIEW_OBJECTS);
define('FEDORA_METADATA_EDIT', ISLANDORA_METADATA_EDIT);
define('FEDORA_ADD_DS', ISLANDORA_ADD_DS);
define('FEDORA_INGEST', ISLANDORA_INGEST);
define('FEDORA_PURGE', ISLANDORA_PURGE);
define('FEDORA_MANAGE_PROPERTIES', ISLANDORA_MANAGE_PROPERTIES);
// @codingStandardsIgnoreEnd
/**
* Implements hook_menu().
*
@ -317,6 +304,16 @@ function islandora_menu() {
'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/replace'] = array(
'title' => 'Replace Datastream',
'page arguments' => array('islandora_datastream_version_replace_form', 4),
'page callback' => 'drupal_get_form',
'file' => 'includes/datastream.version.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_REPLACE_DATASTREAM_CONTENT, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/delete'] = array(
'title' => 'Delete datastream version',
'page arguments' => array('islandora_delete_datastream_version_form', 4, 6),
@ -516,6 +513,10 @@ function islandora_theme() {
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_replace_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_dublin_core_display' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-dublin-core-display',
@ -594,6 +595,10 @@ function islandora_permission() {
'title' => t('Regenerate derivatives'),
'description' => t('Regenerate derivatives for an object or per datastream.'),
),
ISLANDORA_REPLACE_DATASTREAM_CONTENT => array(
'title' => t('Replace datastreams'),
'description' => t('Add new datastream content as latest version.'),
),
);
}
@ -699,6 +704,7 @@ function islandora_forms($form_id) {
* otherwise.
*/
function islandora_user_access($object_or_datastream, array $permissions, $content_models = array(), $access_any = TRUE, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$is_repository_accessible = &drupal_static(__FUNCTION__);
@ -1709,7 +1715,7 @@ function islandora_islandora_basic_collection_get_query_filters() {
if ($enforced) {
$namespace_array = islandora_get_allowed_namespaces();
$namespace_sparql = implode('|', $namespace_array);
return format_string('regex(str(?object), "info:fedora/(!namespaces):")', array('!namespaces' => $namespace_sparql));
return array('islandora_namespace_restrictions' => format_string('regex(str(?object), "info:fedora/(!namespaces):")', array('!namespaces' => $namespace_sparql)));
}
}

31
policies/permit-apim-to-anonymous-user.xml

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PolicyId="permit-apim-to-anonymous-user"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">
<Description>note that other policies may provide exceptions to this broad policy. This policy assumes api-m users have to be authenticated</Description>
<Target>
<Subjects>
<Subject>
<SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">anonymous user</AttributeValue>
<SubjectAttributeDesignator AttributeId="fedoraRole" MustBePresent="false"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
</SubjectMatch>
</Subject>
</Subjects>
<Resources>
<AnyResource/>
</Resources>
<Actions>
<Action>
<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">urn:fedora:names:fedora:2.1:action:api-m</AttributeValue>
<ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
AttributeId="urn:fedora:names:fedora:2.1:action:api"/>
</ActionMatch>
</Action>
</Actions>
</Target>
<Rule RuleId="1" Effect="Permit"/>
</Policy>

31
policies/permit-apim-to-authenticated-user.xml

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PolicyId="permit-apim-to-authenticated-user"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">
<Description>note that other policies may provide exceptions to this broad policy. This policy assumes api-m users have to be authenticated</Description>
<Target>
<Subjects>
<Subject>
<SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">authenticated user</AttributeValue>
<SubjectAttributeDesignator AttributeId="fedoraRole" MustBePresent="false"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
</SubjectMatch>
</Subject>
</Subjects>
<Resources>
<AnyResource/>
</Resources>
<Actions>
<Action>
<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">urn:fedora:names:fedora:2.1:action:api-m</AttributeValue>
<ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
AttributeId="urn:fedora:names:fedora:2.1:action:api"/>
</ActionMatch>
</Action>
</Actions>
</Target>
<Rule RuleId="1" Effect="Permit"/>
</Policy>

25
policies/permit-getDatastream-unrestricted.xml

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PolicyId="permit-getDatastreamHistory-to-authenticated"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">
<Description>Note that other policies may provide exceptions to this broad policy. This policy assumes api-m users have to be authenticated</Description>
<Target>
<Subjects>
<AnySubject/>
</Subjects>
<Resources>
<AnyResource/>
</Resources>
<Actions>
<Action>
<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">urn:fedora:names:fedora:2.1:action:id-getDatastream</AttributeValue>
<ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
AttributeId="urn:fedora:names:fedora:2.1:action:id"/>
</ActionMatch>
</Action>
</Actions>
</Target>
<Rule RuleId="1" Effect="Permit"/>
</Policy>

25
policies/permit-getDatastreamHistory-unrestricted.xml

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PolicyId="permit-getDatastreamHistory-to-authenticated"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">
<Description>Note that other policies may provide exceptions to this broad policy. This policy assumes api-m users have to be authenticated</Description>
<Target>
<Subjects>
<AnySubject/>
</Subjects>
<Resources>
<AnyResource/>
</Resources>
<Actions>
<Action>
<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">urn:fedora:names:fedora:2.1:action:id-getDatastreamHistory</AttributeValue>
<ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
AttributeId="urn:fedora:names:fedora:2.1:action:id"/>
</ActionMatch>
</Action>
</Actions>
</Target>
<Rule RuleId="1" Effect="Permit"/>
</Policy>

31
policies/permit-upload-to-anonymous-user.xml

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PolicyId="permit-upload-to-anonymous-user"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">
<Description></Description>
<Target>
<Subjects>
<Subject>
<SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">anonymous user</AttributeValue>
<SubjectAttributeDesignator AttributeId="fedoraRole" MustBePresent="false"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
</SubjectMatch>
</Subject>
</Subjects>
<Resources>
<AnyResource/>
</Resources>
<Actions>
<Action>
<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">urn:fedora:names:fedora:2.1:action:id-upload</AttributeValue>
<ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
AttributeId="urn:fedora:names:fedora:2.1:action:id"/>
</ActionMatch>
</Action>
</Actions>
</Target>
<Rule RuleId="1" Effect="Permit"/>
</Policy>

31
policies/permit-upload-to-authenticated-user.xml

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Policy xmlns="urn:oasis:names:tc:xacml:1.0:policy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PolicyId="permit-upload-to-authenticated-user"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable">
<Description></Description>
<Target>
<Subjects>
<Subject>
<SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">authenticated user</AttributeValue>
<SubjectAttributeDesignator AttributeId="fedoraRole" MustBePresent="false"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
</SubjectMatch>
</Subject>
</Subjects>
<Resources>
<AnyResource/>
</Resources>
<Actions>
<Action>
<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">urn:fedora:names:fedora:2.1:action:id-upload</AttributeValue>
<ActionAttributeDesignator DataType="http://www.w3.org/2001/XMLSchema#string"
AttributeId="urn:fedora:names:fedora:2.1:action:id"/>
</ActionMatch>
</Action>
</Actions>
</Target>
<Rule RuleId="1" Effect="Permit"/>
</Policy>

2
tests/islandora_hooked_access_test.module

@ -23,7 +23,7 @@ function islandora_hooked_access_test_islandora_object_access($op, $object, $use
* Implements hook_islandora_datastream_access().
*/
function islandora_hooked_access_test_islandora_datastream_access($op, $datastream, $user) {
if ($op == FEDORA_PURGE) {
if ($op == ISLANDORA_PURGE) {
return FALSE;
}
if (isset($_SESSION['islandora_hooked_access_test']) && $_SESSION['islandora_hooked_access_test'] === func_get_args()) {

83
tests/islandora_manage_temp_file.test

@ -0,0 +1,83 @@
<?php
/**
* @file
* Tests for our islandora_temp_file_entry() function.
*/
class IslandoraManageTempfileTestCase extends IslandoraWebTestCase {
/**
* Gets info to display to describe this test.
*
* @see IslandoraWebTestCase::getInfo()
*/
public static function getInfo() {
return array(
'name' => 'Islandora Managed Tempfile Interface',
'description' => 'Ensure that our managed tempfile interface returns appropriate results.',
'group' => 'Islandora',
);
}
/**
* Creates an admin user and a connection to a fedora repository.
*
* @see IslandoraWebTestCase::setUp()
*/
public function setUp() {
parent::setUp('islandora');
$this->tempUri = file_create_filename('temp.txt', 'temporary://');
$this->publicUri = file_create_filename('temp.txt', 'public://');
}
/**
* Free any objects/resources created for this test.
*
* @see IslandoraWebTestCase::tearDown()
*/
public function tearDown() {
parent::tearDown();
file_unmanaged_delete($this->tempUri);
file_unmanaged_delete($this->publicUri);
}
/**
* Existing files are made temporary.
*/
public function testExistingFile() {
$temp_file = file_save_data('blah', $this->tempUri, FILE_EXISTS_REPLACE);
$public_file = file_save_data('blah', $this->publicUri, FILE_EXISTS_REPLACE);
$this->existingFileHelper($temp_file);
$this->existingFileHelper($public_file);
}
/**
* Helper function; ensure file is permanent (as file_save_data() creates).
*/
protected function existingFileHelper($file_object) {
$this->assertEqual($file_object->status & FILE_STATUS_PERMANENT, FILE_STATUS_PERMANENT, 'Existing file is permanent.');
$this->baseFileHelper($file_object->uri);
$this->assertTrue(file_delete($file_object));
}
/**
* Helper function; ensure our function produces an temporary file object.
*/
protected function baseFileHelper($file_uri) {
$temp_file = islandora_temp_file_entry($file_uri);
$this->assertNotEqual($temp_file->status & FILE_STATUS_PERMANENT, FILE_STATUS_PERMANENT, 'File has been made temporary.');
}
/**
* Unmanaged files start being managed.
*/
public function testNewFileUri() {
file_put_contents($this->tempUri, 'test');
file_put_contents($this->publicUri, 'test');
$this->baseFileHelper($this->tempUri);
$this->baseFileHelper($this->publicUri);
}
}

2
tests/scripts/travis_setup.sh

@ -51,4 +51,6 @@ drush en --yes simpletest
drush en --yes potx
drush en --user=1 --yes islandora
drush cc all
# The shebang in this file is a bogeyman that is haunting the web test cases.
rm /home/travis/.phpenv/rbenv.d/exec/hhvm-switcher.bash
sleep 20

30
theme/theme.inc

@ -25,7 +25,7 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
$header[] = array('data' => t('Versions'));
}
$header[] = array('data' => t('Operations'), 'colspan' => '4');
$header[] = array('data' => t('Operations'), 'colspan' => '5');
$table_attributes = array('class' => array('manage-datastreams'));
$rows = array();
@ -60,6 +60,13 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
'datastream' => $ds,
)),
);
// Add new datastream content as the lastest version.
$row[] = array(
'class' => 'datastream-replace',
'data' => theme('islandora_datastream_replace_link', array(
'datastream' => $ds,
)),
);
}
$row[] = array(
'class' => 'datastream-download',
@ -436,6 +443,27 @@ function theme_islandora_datastream_version_link(array $vars) {
}
}
/**
* Renders a link to take you to the datastream add latest version page.
*
* @param array $vars
* An array containing:
* - datastream: An AbstractDatastream to generate a new version.
*
* @return string
* Markup.
*/
function theme_islandora_datastream_replace_link(array $vars) {
$datastream = $vars['datastream'];
if (islandora_datastream_access(ISLANDORA_REPLACE_DATASTREAM_CONTENT, $datastream)) {
$var_string = variable_get("islandora_ds_replace_exclude_enforced", "RELS-EXT,RELS-INT");
$replace_exclude = explode(",", $var_string);
if (!in_array($datastream->id, $replace_exclude)) {
return l(t('replace'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/replace");
}
}
}
/**
* Renders a link that will re-create derivatives for a datastream.
*

Loading…
Cancel
Save