Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x-derivatives

Conflicts:
	islandora.api.php
pull/380/head
Jordan Dukart 11 years ago
parent
commit
b5b691f8aa
  1. 6
      includes/authtokens.inc
  2. 2
      includes/object_properties.form.inc
  3. 4
      includes/utilities.inc
  4. 31
      islandora.api.php
  5. 14
      islandora.drush.inc
  6. 94
      islandora.module
  7. 4
      js/add_print.js
  8. 2
      tests/authtokens.test
  9. 6
      tests/hooked_access.test
  10. 5
      tests/islandora_hooked_access_test.module
  11. 50
      tests/islandora_manage_permissions.test
  12. 18
      theme/theme.inc

6
includes/authtokens.inc

@ -10,7 +10,7 @@
// Token lifespan(seconds): after this duration the token expires. // Token lifespan(seconds): after this duration the token expires.
// 5 minutes. // 5 minutes.
define('TOKEN_TIMEOUT', 300); define('ISLANDORA_AUTHTOKEN_TOKEN_TIMEOUT', 300);
/** /**
* Request Islandora to construct an object/datastream authentication token. * Request Islandora to construct an object/datastream authentication token.
@ -92,7 +92,7 @@ function islandora_validate_object_token($pid, $dsid, $token) {
->condition('pid', $pid, '=') ->condition('pid', $pid, '=')
->condition('dsid', $dsid, '=') ->condition('dsid', $dsid, '=')
->condition('time', $time, '<=') ->condition('time', $time, '<=')
->condition('time', $time - TOKEN_TIMEOUT, '>') ->condition('time', $time - ISLANDORA_AUTHTOKEN_TOKEN_TIMEOUT, '>')
->execute() ->execute()
->fetchAll(); ->fetchAll();
if ($result) { if ($result) {
@ -131,6 +131,6 @@ function islandora_validate_object_token($pid, $dsid, $token) {
function islandora_remove_expired_tokens() { function islandora_remove_expired_tokens() {
$time = time(); $time = time();
db_delete("islandora_authtokens") db_delete("islandora_authtokens")
->condition('time', $time - TOKEN_TIMEOUT, '<') ->condition('time', $time - ISLANDORA_AUTHTOKEN_TOKEN_TIMEOUT, '<')
->execute(); ->execute();
} }

2
includes/object_properties.form.inc

@ -60,7 +60,7 @@ function islandora_object_properties_form(array $form, array &$form_state, Abstr
), ),
'delete' => array( 'delete' => array(
'#type' => 'submit', '#type' => 'submit',
'#access' => islandora_object_access(FEDORA_PURGE, $object), '#access' => islandora_object_access(ISLANDORA_PURGE, $object),
'#value' => t('Delete'), '#value' => t('Delete'),
'#submit' => array('islandora_object_properties_form_delete'), '#submit' => array('islandora_object_properties_form_delete'),
'#limit_validation_errors' => array(array('pid')), '#limit_validation_errors' => array(array('pid')),

4
includes/utilities.inc

@ -391,10 +391,10 @@ function islandora_get_datastreams_requirements_from_models(array $models) {
* - "optional": A boolean indicating if the given stream is optional. * - "optional": A boolean indicating if the given stream is optional.
*/ */
function islandora_get_datastreams_requirements_from_content_model(AbstractObject $object) { function islandora_get_datastreams_requirements_from_content_model(AbstractObject $object) {
if (empty($object[DS_COMP_STREAM]) || !islandora_datastream_access(FEDORA_VIEW_OBJECTS, $object[DS_COMP_STREAM])) { if (empty($object[ISLANDORA_DS_COMP_STREAM]) || !islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[ISLANDORA_DS_COMP_STREAM])) {
return array(); return array();
} }
$xml = new SimpleXMLElement($object[DS_COMP_STREAM]->content); $xml = new SimpleXMLElement($object[ISLANDORA_DS_COMP_STREAM]->content);
foreach ($xml->dsTypeModel as $ds) { foreach ($xml->dsTypeModel as $ds) {
$dsid = (string) $ds['ID']; $dsid = (string) $ds['ID'];
$optional = strtolower((string) $ds['optional']); $optional = strtolower((string) $ds['optional']);

31
islandora.api.php

@ -543,6 +543,37 @@ function hook_CMODEL_PID_islandora_datastream_access($op, $object, $user) {
} }
/** /**
* Lets one add to the overview tab in object management.
*/
function hook_islandora_overview_object(AbstractObject $object) {
return drupal_render(drupal_get_form('some_form', $object));
}
/**
* Lets one add to the overview tab in object management.
*
* Content model specific.
*/
function hook_CMODEL_PID_islandora_overview_object(AbstractObject $object) {
return drupal_render(drupal_get_form('some_form', $object));
}
/**
* Lets one alter the overview tab in object management.
*/
function hook_islandora_overview_object_alter(AbstractObject &$object, &$output) {
$output = $output . drupal_render(drupal_get_form('some_form', $object));
}
/**
* Lets one alter the overview tab in object management.
*
* Content model specific.
*/
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. * Defines derivative functions to be executed based on certain conditions.
* *
* This hook fires when an object/datastream is ingested or a datastream is * This hook fires when an object/datastream is ingested or a datastream is

14
islandora.drush.inc

@ -26,6 +26,10 @@ function islandora_drush_command() {
'drupal dependencies' => array( 'drupal dependencies' => array(
'islandora', 'islandora',
), ),
'examples' => array(
'drush -u 1 ispiro --module=islandora' => dt('Install missing solution pack objects for the "islandora" module.'),
'drush -u 1 ispiro --module=islandora --force' => dt('Install all solution pack objects for the "islandora" module, purging any which currently exist.'),
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
); );
$commands['islandora-solution-pack-uninstall-required-objects'] = array( $commands['islandora-solution-pack-uninstall-required-objects'] = array(
@ -36,13 +40,17 @@ function islandora_drush_command() {
'required' => TRUE, 'required' => TRUE,
), ),
'force' => array( 'force' => array(
'description' => dt('Force reinstallation of the objects.'), 'description' => dt('Force uninstallation of the objects.'),
), ),
), ),
'aliases' => array('ispuro'), 'aliases' => array('ispuro'),
'drupal dependencies' => array( 'drupal dependencies' => array(
'islandora', 'islandora',
), ),
'examples' => array(
'drush -u 1 ispuro --module=islandora' => dt('Uninstall solution pack objects for the "islandora" module.'),
'drush -u 1 ispuro --module=islandora --force' => dt('Force uninstallation of all solution pack objects for the "islandora" module.'),
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
); );
$commands['islandora-solution-pack-required-objects-status'] = array( $commands['islandora-solution-pack-required-objects-status'] = array(
@ -56,6 +64,10 @@ function islandora_drush_command() {
'drupal dependencies' => array( 'drupal dependencies' => array(
'islandora', 'islandora',
), ),
'examples' => array(
'drush -u 1 ispros' => dt('Get the status of all solution pack objects.'),
'drush -u 1 ispros --module=islandora' => dt('Get the status of solution pack objects for the "islandora" module.'),
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
); );

94
islandora.module

@ -24,15 +24,15 @@
*/ */
// Common datastreams. // Common datastreams.
define('DS_COMP_STREAM', 'DS-COMPOSITE-MODEL'); define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
// Permissions. // Permissions.
define('FEDORA_VIEW_OBJECTS', 'view fedora repository objects'); define('ISLANDORA_VIEW_OBJECTS', 'view fedora repository objects');
define('FEDORA_METADATA_EDIT', 'edit fedora metadata'); define('ISLANDORA_METADATA_EDIT', 'edit fedora metadata');
define('FEDORA_ADD_DS', 'add fedora datastreams'); define('ISLANDORA_ADD_DS', 'add fedora datastreams');
define('FEDORA_INGEST', 'ingest fedora objects'); define('ISLANDORA_INGEST', 'ingest fedora objects');
define('FEDORA_PURGE', 'delete fedora objects and datastreams'); define('ISLANDORA_PURGE', 'delete fedora objects and datastreams');
define('FEDORA_MANAGE_PROPERTIES', 'manage object properties'); define('ISLANDORA_MANAGE_PROPERTIES', 'manage object properties');
define('ISLANDORA_VIEW_DATASTREAM_HISTORY', 'view old datastream versions'); define('ISLANDORA_VIEW_DATASTREAM_HISTORY', 'view old datastream versions');
// Hooks. // Hooks.
@ -58,6 +58,19 @@ define('ISLANDORA_DERVIATIVE_CREATION_HOOK', 'islandora_derivative');
// Autocomplete paths. // Autocomplete paths.
define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models'); define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models');
/**
* @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(). * Implements hook_menu().
* *
@ -86,7 +99,7 @@ function islandora_menu() {
'title' => 'Solution packs', 'title' => 'Solution packs',
'description' => 'Install content models and collections required by installed solution packs.', 'description' => 'Install content models and collections required by installed solution packs.',
'page callback' => 'islandora_solution_packs_admin', 'page callback' => 'islandora_solution_packs_admin',
'access arguments' => array(FEDORA_ADD_DS), 'access arguments' => array(ISLANDORA_ADD_DS),
'file' => 'includes/solution_packs.inc', 'file' => 'includes/solution_packs.inc',
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
); );
@ -94,7 +107,7 @@ function islandora_menu() {
'title' => 'Islandora Repository', 'title' => 'Islandora Repository',
'page callback' => 'islandora_view_default_object', 'page callback' => 'islandora_view_default_object',
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_VIEW_OBJECTS), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS),
); );
$items['islandora/object/%islandora_object'] = array( $items['islandora/object/%islandora_object'] = array(
'title callback' => 'islandora_drupal_title', 'title callback' => 'islandora_drupal_title',
@ -103,14 +116,14 @@ function islandora_menu() {
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access callback' => 'islandora_object_access_callback', 'access callback' => 'islandora_object_access_callback',
'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
); );
$items['islandora/object/%islandora_object/print'] = array( $items['islandora/object/%islandora_object/print'] = array(
'page callback' => 'islandora_printer_object', 'page callback' => 'islandora_printer_object',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access callback' => 'islandora_object_access_callback', 'access callback' => 'islandora_object_access_callback',
'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
); );
$items['islandora/object/%islandora_object/view'] = array( $items['islandora/object/%islandora_object/view'] = array(
'title' => 'View', 'title' => 'View',
@ -130,11 +143,11 @@ function islandora_menu() {
'access callback' => 'islandora_object_manage_access_callback', 'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array( 'access arguments' => array(
array( array(
FEDORA_MANAGE_PROPERTIES, ISLANDORA_MANAGE_PROPERTIES,
FEDORA_METADATA_EDIT, ISLANDORA_METADATA_EDIT,
FEDORA_ADD_DS, ISLANDORA_ADD_DS,
FEDORA_PURGE, ISLANDORA_PURGE,
FEDORA_INGEST, ISLANDORA_INGEST,
), 2), ), 2),
); );
@ -152,9 +165,9 @@ function islandora_menu() {
'access callback' => 'islandora_object_manage_access_callback', 'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array( 'access arguments' => array(
array( array(
FEDORA_METADATA_EDIT, ISLANDORA_METADATA_EDIT,
FEDORA_ADD_DS, ISLANDORA_ADD_DS,
FEDORA_PURGE, ISLANDORA_PURGE,
), 2), ), 2),
'weight' => -10, 'weight' => -10,
); );
@ -166,7 +179,7 @@ function islandora_menu() {
'page arguments' => array('islandora_object_properties_form', 2), 'page arguments' => array('islandora_object_properties_form', 2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_object_access_callback', 'access callback' => 'islandora_object_access_callback',
'access arguments' => array(FEDORA_MANAGE_PROPERTIES, 2), 'access arguments' => array(ISLANDORA_MANAGE_PROPERTIES, 2),
'weight' => -5, 'weight' => -5,
); );
$items['islandora/object/%islandora_object/delete'] = array( $items['islandora/object/%islandora_object/delete'] = array(
@ -176,7 +189,7 @@ function islandora_menu() {
'page arguments' => array('islandora_delete_object_form', 2), 'page arguments' => array('islandora_delete_object_form', 2),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access_callback', 'access callback' => 'islandora_object_access_callback',
'access arguments' => array(FEDORA_PURGE, 2), 'access arguments' => array(ISLANDORA_PURGE, 2),
); );
$items['islandora/object/%islandora_object/manage/datastreams/add'] = array( $items['islandora/object/%islandora_object/manage/datastreams/add'] = array(
'title' => 'Add a datastream', 'title' => 'Add a datastream',
@ -185,7 +198,7 @@ function islandora_menu() {
'page arguments' => array('islandora_add_datastream_form', 2), 'page arguments' => array('islandora_add_datastream_form', 2),
'type' => MENU_LOCAL_ACTION, 'type' => MENU_LOCAL_ACTION,
'access callback' => 'islandora_object_access_callback', 'access callback' => 'islandora_object_access_callback',
'access arguments' => array(FEDORA_ADD_DS, 2), 'access arguments' => array(ISLANDORA_ADD_DS, 2),
); );
$items['islandora/object/%islandora_object/manage/datastreams/add/autocomplete'] = array( $items['islandora/object/%islandora_object/manage/datastreams/add/autocomplete'] = array(
'file' => 'includes/add_datastream.form.inc', 'file' => 'includes/add_datastream.form.inc',
@ -193,7 +206,7 @@ function islandora_menu() {
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access_callback', 'access callback' => 'islandora_object_access_callback',
'access arguments' => array(FEDORA_ADD_DS, 2), 'access arguments' => array(ISLANDORA_ADD_DS, 2),
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
@ -202,7 +215,7 @@ function islandora_menu() {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access', 'access callback' => 'islandora_datastream_access',
'access arguments' => array(FEDORA_VIEW_OBJECTS, 4), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 4),
'load arguments' => array(2), 'load arguments' => array(2),
); );
// This menu item uses token authentication in islandora_tokened_object. // This menu item uses token authentication in islandora_tokened_object.
@ -210,7 +223,7 @@ function islandora_menu() {
'title' => 'View datastream', 'title' => 'View datastream',
'load arguments' => array('%map'), 'load arguments' => array('%map'),
'access callback' => 'islandora_object_datastream_tokened_access_callback', 'access callback' => 'islandora_object_datastream_tokened_access_callback',
'access arguments' => array(FEDORA_VIEW_OBJECTS, 2, 4), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2, 4),
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/download'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream/download'] = array(
@ -220,7 +233,7 @@ function islandora_menu() {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access', 'access callback' => 'islandora_datastream_access',
'access arguments' => array(FEDORA_VIEW_OBJECTS, 4), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 4),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/edit'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream/edit'] = array(
@ -230,7 +243,7 @@ function islandora_menu() {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access', 'access callback' => 'islandora_datastream_access',
'access arguments' => array(FEDORA_METADATA_EDIT, 4), 'access arguments' => array(ISLANDORA_METADATA_EDIT, 4),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/delete'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream/delete'] = array(
@ -240,7 +253,7 @@ function islandora_menu() {
'file' => 'includes/delete_datastream.form.inc', 'file' => 'includes/delete_datastream.form.inc',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access', 'access callback' => 'islandora_datastream_access',
'access arguments' => array(FEDORA_PURGE, 4), 'access arguments' => array(ISLANDORA_PURGE, 4),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version'] = array(
@ -260,7 +273,7 @@ function islandora_menu() {
'file' => 'includes/datastream.version.inc', 'file' => 'includes/datastream.version.inc',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access', 'access callback' => 'islandora_datastream_access',
'access arguments' => array(FEDORA_PURGE, 4), 'access arguments' => array(ISLANDORA_PURGE, 4),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/view'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/view'] = array(
@ -278,7 +291,7 @@ function islandora_menu() {
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access', 'access callback' => 'islandora_object_access',
'access arguments' => array(FEDORA_VIEW_OBJECTS, 2), 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items[ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE] = array( $items[ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE] = array(
@ -391,27 +404,27 @@ function islandora_theme() {
*/ */
function islandora_permission() { function islandora_permission() {
return array( return array(
FEDORA_VIEW_OBJECTS => array( ISLANDORA_VIEW_OBJECTS => array(
'title' => t('View repository objects'), 'title' => t('View repository objects'),
'description' => t('View objects in the repository. Note: Fedora XACML security policies may override this permission.'), 'description' => t('View objects in the repository. Note: Fedora XACML security policies may override this permission.'),
), ),
FEDORA_ADD_DS => array( ISLANDORA_ADD_DS => array(
'title' => t('Add datastreams to repository objects'), 'title' => t('Add datastreams to repository objects'),
'description' => t('Add datastreams to objects in the repository. Note: Fedora XACML security policies may override this position.'), 'description' => t('Add datastreams to objects in the repository. Note: Fedora XACML security policies may override this position.'),
), ),
FEDORA_METADATA_EDIT => array( ISLANDORA_METADATA_EDIT => array(
'title' => t('Edit metadata'), 'title' => t('Edit metadata'),
'description' => t('Edit metadata for objects in the repository.'), 'description' => t('Edit metadata for objects in the repository.'),
), ),
FEDORA_INGEST => array( ISLANDORA_INGEST => array(
'title' => t('Create new repository objects'), 'title' => t('Create new repository objects'),
'description' => t('Create new objects in the repository.'), 'description' => t('Create new objects in the repository.'),
), ),
FEDORA_PURGE => array( ISLANDORA_PURGE => array(
'title' => t('Permanently remove objects from the repository'), 'title' => t('Permanently remove objects from the repository'),
'description' => t('Permanently remove objects from the repository.'), 'description' => t('Permanently remove objects from the repository.'),
), ),
FEDORA_MANAGE_PROPERTIES => array( ISLANDORA_MANAGE_PROPERTIES => array(
'title' => t('Manage object properties'), 'title' => t('Manage object properties'),
'description' => t('Modify object labels, owner IDs, and states.'), 'description' => t('Modify object labels, owner IDs, and states.'),
), ),
@ -803,7 +816,7 @@ function islandora_view_object(AbstractObject $object) {
drupal_add_js(array( drupal_add_js(array(
'islandora' => array( 'islandora' => array(
'print_link' => '/islandora/object/' . $object->id . '/print')), 'print_link' => 'islandora/object/' . $object->id . '/print')),
array('type' => 'setting')); array('type' => 'setting'));
drupal_add_js($path . '/js/add_print.js'); drupal_add_js($path . '/js/add_print.js');
@ -1440,7 +1453,7 @@ function islandora_islandora_object_access($op, $object, $user) {
/** /**
* Hookable access callback for datastreams. * Hookable access callback for datastreams.
* *
* Requires the equivalent permissions on the object. * Positive permissions on object access suggests on the datastream.
*/ */
function islandora_datastream_access($op, $datastream, $user = NULL) { function islandora_datastream_access($op, $datastream, $user = NULL) {
$cache = &drupal_static(__FUNCTION__); $cache = &drupal_static(__FUNCTION__);
@ -1469,10 +1482,9 @@ function islandora_datastream_access($op, $datastream, $user = NULL) {
$user, $user,
)); ));
// Neither the object nor the datastream check returned FALSE, and one in // The datastream check returned FALSE, and one in the object or datastream
// the object or datastream checks returned TRUE. // checks returned TRUE.
$cache[$op][$datastream->parent->id][$datastream->id][$user->uid] = ( $cache[$op][$datastream->parent->id][$datastream->id][$user->uid] = (
!in_array(FALSE, $object_results, TRUE) &&
!in_array(FALSE, $datastream_results, TRUE) && !in_array(FALSE, $datastream_results, TRUE) &&
(in_array(TRUE, $object_results, TRUE) || in_array(TRUE, $datastream_results, TRUE)) (in_array(TRUE, $object_results, TRUE) || in_array(TRUE, $datastream_results, TRUE))
); );

4
js/add_print.js

@ -8,10 +8,10 @@
*/ */
(function ($) { (function ($) {
$(document).ready(function() { $(document).ready(function() {
$('.tabs .primary').append('<img id="print_btn" title="Print" src="/' + Drupal.settings.islandora.print_img + '"></img>'); $('.tabs .primary').append('<img id="print_btn" title="Print" src="' + Drupal.settings.basePath + Drupal.settings.islandora.print_img + '"></img>');
$('#print_btn').css("cursor","pointer"); $('#print_btn').css("cursor","pointer");
$('#print_btn').click(function() { $('#print_btn').click(function() {
window.location=Drupal.settings.islandora.print_link; window.location=Drupal.settings.basePath + Drupal.settings.islandora.print_link;
}); });
}); });
})(jQuery); })(jQuery);

2
tests/authtokens.test

@ -74,7 +74,7 @@ class IslandoraAuthtokensTestCase extends IslandoraWebTestCase {
$this->drupalGet("islandora/object/{$newpid}/datastream/JP2/view"); $this->drupalGet("islandora/object/{$newpid}/datastream/JP2/view");
$this->assertResponse(403, 'Page not found as anonymous'); $this->assertResponse(403, 'Page not found as anonymous');
$account = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS)); $account = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS));
$this->drupalLogin($account); $this->drupalLogin($account);
$this->drupalGet("islandora/object/{$newpid}/datastream/JP2/view"); $this->drupalGet("islandora/object/{$newpid}/datastream/JP2/view");

6
tests/hooked_access.test

@ -37,9 +37,9 @@ class IslandoraHookedAccessTestCase extends IslandoraWebTestCase {
$this->objects = array( $this->objects = array(
'test:testAccessHook', 'test:testAccessHook',
); );
$this->op = FEDORA_VIEW_OBJECTS; $this->op = ISLANDORA_VIEW_OBJECTS;
$this->other_op = FEDORA_INGEST; $this->other_op = ISLANDORA_INGEST;
$this->denied_op = FEDORA_PURGE; $this->denied_op = ISLANDORA_PURGE;
$this->purgeTestObjects(); $this->purgeTestObjects();
$this->dsid = 'asdf'; $this->dsid = 'asdf';
$this->createTestObjects(); $this->createTestObjects();

5
tests/islandora_hooked_access_test.module

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

50
tests/islandora_manage_permissions.test

@ -33,16 +33,16 @@ class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
* Test manage permissions. * Test manage permissions.
*/ */
public function testManagePermissions() { public function testManagePermissions() {
// Test permission FEDORA_VIEW_OBJECTS. // Test permission ISLANDORA_VIEW_OBJECTS.
// Create a user with permission. // Create a user with permission.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS));
// Log the user in. // Log the user in.
$this->drupalLogin($user); $this->drupalLogin($user);
$this->clickLink(t('Islandora Repository')); $this->clickLink(t('Islandora Repository'));
$this->assertNoLink('Manage', 'Manage tab is not on current page.'); $this->assertNoLink('Manage', 'Manage tab is not on current page.');
// Test permission FEDORA_VIEW_OBJECTS, FEDORA_MANAGE_PROPERTIES. // Test permission ISLANDORA_VIEW_OBJECTS, ISLANDORA_MANAGE_PROPERTIES.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS, FEDORA_MANAGE_PROPERTIES)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_MANAGE_PROPERTIES));
$this->drupalLogin($user); $this->drupalLogin($user);
$this->clickLink(t('Islandora Repository')); $this->clickLink(t('Islandora Repository'));
$this->assertLink('Manage', 0, 'Manage tab is on current page.'); $this->assertLink('Manage', 0, 'Manage tab is on current page.');
@ -51,8 +51,8 @@ class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
$this->assertNoLink('Datastreams', 'Datastreams tab is not on current page.'); $this->assertNoLink('Datastreams', 'Datastreams tab is not on current page.');
$this->assertNoLink('Collection', 'Collection tab is not on current page.'); $this->assertNoLink('Collection', 'Collection tab is not on current page.');
// Test permission FEDORA_VIEW_OBJECTS, FEDORA_ADD_DS. // Test permission ISLANDORA_VIEW_OBJECTS, ISLANDORA_ADD_DS.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS, FEDORA_ADD_DS)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_ADD_DS));
$this->drupalLogin($user); $this->drupalLogin($user);
$this->clickLink(t('Islandora Repository')); $this->clickLink(t('Islandora Repository'));
$this->assertLink('Manage', 0, 'Manage tab is on current page.'); $this->assertLink('Manage', 0, 'Manage tab is on current page.');
@ -61,8 +61,8 @@ class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
$this->assertNoLink('Properties', 'Properties tab is not on current page.'); $this->assertNoLink('Properties', 'Properties tab is not on current page.');
$this->assertNoLink('Collection', 'Collection tab is not on current page.'); $this->assertNoLink('Collection', 'Collection tab is not on current page.');
// Test permission FEDORA_VIEW_OBJECTS, FEDORA_METADATA_EDIT. // Test permission ISLANDORA_VIEW_OBJECTS, ISLANDORA_METADATA_EDIT.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS, FEDORA_METADATA_EDIT)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_METADATA_EDIT));
$this->drupalLogin($user); $this->drupalLogin($user);
$this->clickLink(t('Islandora Repository')); $this->clickLink(t('Islandora Repository'));
$this->assertLink('Manage', 0, 'Manage tab is on current page.'); $this->assertLink('Manage', 0, 'Manage tab is on current page.');
@ -71,8 +71,8 @@ class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
$this->assertNoLink('Properties', 'Properties tab is not on current page.'); $this->assertNoLink('Properties', 'Properties tab is not on current page.');
$this->assertNoLink('Collection', 'Collection tab is not on current page.'); $this->assertNoLink('Collection', 'Collection tab is not on current page.');
// Test permission FEDORA_VIEW_OBJECTS, FEDORA_PURGE. // Test permission ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS, FEDORA_PURGE)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE));
$this->drupalLogin($user); $this->drupalLogin($user);
$this->clickLink(t('Islandora Repository')); $this->clickLink(t('Islandora Repository'));
$this->assertLink('Manage', 0, 'Manage tab is on current page.'); $this->assertLink('Manage', 0, 'Manage tab is on current page.');
@ -98,39 +98,39 @@ class IslandoraPermissionsTestCase extends IslandoraWebTestCase {
$ret = islandora_user_access($object, array()); $ret = islandora_user_access($object, array());
$this->assertFalse($ret, 'User access denied when no permissions are provided.'); $this->assertFalse($ret, 'User access denied when no permissions are provided.');
// Test access with matching permission. // Test access with matching permission.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS));
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS), array(), TRUE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS), array(), TRUE, $user);
$this->assertTrue($ret, 'User access granted when permissions match.'); $this->assertTrue($ret, 'User access granted when permissions match.');
// Test access with matching permission but access any is FALSE. // Test access with matching permission but access any is FALSE.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS));
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS, FEDORA_PURGE), array(), FALSE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE), array(), FALSE, $user);
$this->assertFalse($ret, 'User access denied for matching permission but with access any set to FALSE.'); $this->assertFalse($ret, 'User access denied for matching permission but with access any set to FALSE.');
// Test access with non-matching permission. // Test access with non-matching permission.
$user = $this->drupalCreateUser(array(FEDORA_PURGE)); $user = $this->drupalCreateUser(array(ISLANDORA_PURGE));
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS), array(), TRUE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS), array(), TRUE, $user);
$this->assertFalse($ret, 'User access denied when permissions did not match.'); $this->assertFalse($ret, 'User access denied when permissions did not match.');
// Test access with both permissions and content model. // Test access with both permissions and content model.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS));
$model = $object->models; $model = $object->models;
$model = reset($model); $model = reset($model);
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS), array($model), TRUE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS), array($model), TRUE, $user);
$this->assertTrue($ret, 'User access granted for matching permission and model.'); $this->assertTrue($ret, 'User access granted for matching permission and model.');
// Test access with matching permissions and non-matching content model. // Test access with matching permissions and non-matching content model.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS));
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS), array('islandora:obviouslyNotACModel'), TRUE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS), array('islandora:obviouslyNotACModel'), TRUE, $user);
$this->assertFalse($ret, 'User access denied for matching permission and non-matching model.'); $this->assertFalse($ret, 'User access denied for matching permission and non-matching model.');
// Test access with all matching permissions and one matching model but // Test access with all matching permissions and one matching model but
// access any is FALSE. // access any is FALSE.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS, FEDORA_PURGE)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE));
$model = $object->models; $model = $object->models;
$model = reset($model); $model = reset($model);
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS, FEDORA_PURGE), array($model, 'islandora:obviouslyNotACModel'), FALSE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE), array($model, 'islandora:obviouslyNotACModel'), FALSE, $user);
$this->assertFalse($ret, 'User access denied for all matching permissions and one matching model but with access any set to FALSE.'); $this->assertFalse($ret, 'User access denied for all matching permissions and one matching model but with access any set to FALSE.');
$ret = islandora_user_access($object, array(FEDORA_VIEW_OBJECTS, FEDORA_PURGE), array($model), FALSE, $user); $ret = islandora_user_access($object, array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE), array($model), FALSE, $user);
$this->assertTrue($ret, 'User access granted for all matching permissions and matching models with access any set to FALSE.'); $this->assertTrue($ret, 'User access granted for all matching permissions and matching models with access any set to FALSE.');
// Test passing in a Datastream. // Test passing in a Datastream.
$user = $this->drupalCreateUser(array(FEDORA_VIEW_OBJECTS, FEDORA_PURGE)); $user = $this->drupalCreateUser(array(ISLANDORA_VIEW_OBJECTS, ISLANDORA_PURGE));
$ret = islandora_user_access($object['DC'], array(FEDORA_VIEW_OBJECTS), array(), TRUE, $user); $ret = islandora_user_access($object['DC'], array(ISLANDORA_VIEW_OBJECTS), array(), TRUE, $user);
$this->assertTrue($ret, 'User access granted for matching permissions, with a datastream given instead of an object.'); $this->assertTrue($ret, 'User access granted for matching permissions, with a datastream given instead of an object.');
} }
} }

18
theme/theme.inc

@ -115,7 +115,7 @@ function islandora_preprocess_islandora_default(&$variables) {
$download_path = islandora_datastream_get_url($ds, 'download'); $download_path = islandora_datastream_get_url($ds, 'download');
$datastreams[$id]['id'] = $id; $datastreams[$id]['id'] = $id;
$datastreams[$id]['label'] = $label; $datastreams[$id]['label'] = $label;
$datastreams[$id]['label_link'] = islandora_datastream_access(FEDORA_VIEW_OBJECTS, $ds) ? $datastreams[$id]['label_link'] = islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $ds) ?
l($label, $download_path) : l($label, $download_path) :
$label; $label;
$datastreams[$id]['download_url'] = $download_path; $datastreams[$id]['download_url'] = $download_path;
@ -130,14 +130,14 @@ function islandora_preprocess_islandora_default(&$variables) {
} }
$variables['datastreams'] = $datastreams; $variables['datastreams'] = $datastreams;
// Objects in fcrepo4 don't always contain a DC datastream. // Objects in fcrepo4 don't always contain a DC datastream.
if (isset($islandora_object['DC']) && islandora_datastream_access(FEDORA_VIEW_OBJECTS, $islandora_object['DC'])) { if (isset($islandora_object['DC']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['DC'])) {
$dc_object = DublinCore::importFromXMLString($islandora_object['DC']->content); $dc_object = DublinCore::importFromXMLString($islandora_object['DC']->content);
$dc_array = $dc_object->asArray(); $dc_array = $dc_object->asArray();
} }
$variables['dc_array'] = isset($dc_array) ? $dc_array : array(); $variables['dc_array'] = isset($dc_array) ? $dc_array : array();
$variables['islandora_dublin_core'] = isset($dc_object) ? $dc_object : NULL; $variables['islandora_dublin_core'] = isset($dc_object) ? $dc_object : NULL;
$variables['islandora_object_label'] = $islandora_object->label; $variables['islandora_object_label'] = $islandora_object->label;
if (isset($islandora_object['TN']) && islandora_datastream_access(FEDORA_VIEW_OBJECTS, $islandora_object['TN'])) { if (isset($islandora_object['TN']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = url("islandora/object/{$islandora_object->id}/datastream/TN/view"); $variables['islandora_thumbnail_url'] = url("islandora/object/{$islandora_object->id}/datastream/TN/view");
} }
} }
@ -219,11 +219,11 @@ function islandora_preprocess_islandora_objects(array &$variables) {
$o = islandora_object_load($o); $o = islandora_object_load($o);
$url = "islandora/object/{$o->id}"; $url = "islandora/object/{$o->id}";
$link_options = array('html' => TRUE, 'attributes' => array('title' => $o->label)); $link_options = array('html' => TRUE, 'attributes' => array('title' => $o->label));
$img = islandora_datastream_access(FEDORA_VIEW_OBJECTS, $o['TN']) ? $img = islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $o['TN']) ?
theme('image', array('path' => url("$url/datastream/TN/view"), 'attributes' => array())) : theme('image', array('path' => url("$url/datastream/TN/view"), 'attributes' => array())) :
''; '';
$description = NULL; $description = NULL;
if (isset($o['DC']) && islandora_datastream_access(FEDORA_VIEW_OBJECTS, $o['DC'])) { if (isset($o['DC']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $o['DC'])) {
$dc = DublinCore::importFromXMLString($o['DC']->content); $dc = DublinCore::importFromXMLString($o['DC']->content);
if ($dc) { if ($dc) {
$dc = $dc->asArray(); $dc = $dc->asArray();
@ -260,7 +260,7 @@ function theme_islandora_datastream_download_link(array $vars) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$label = t('download'); $label = t('download');
return islandora_datastream_access(FEDORA_VIEW_OBJECTS, $datastream) ? return islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $datastream) ?
l($label, islandora_datastream_get_url($datastream, 'download')) : l($label, islandora_datastream_get_url($datastream, 'download')) :
''; '';
} }
@ -289,7 +289,7 @@ function theme_islandora_datastream_view_link(array $vars) {
} }
if ($vars['version'] === NULL) { if ($vars['version'] === NULL) {
$perm = FEDORA_VIEW_OBJECTS; $perm = ISLANDORA_VIEW_OBJECTS;
} }
else { else {
$perm = ISLANDORA_VIEW_DATASTREAM_HISTORY; $perm = ISLANDORA_VIEW_DATASTREAM_HISTORY;
@ -319,7 +319,7 @@ function theme_islandora_datastream_delete_link(array $vars) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models); $datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models);
$can_delete = !in_array($datastream->id, $datastreams) && islandora_datastream_access(FEDORA_PURGE, $datastream); $can_delete = !in_array($datastream->id, $datastreams) && islandora_datastream_access(ISLANDORA_PURGE, $datastream);
if ($vars['version'] !== NULL) { if ($vars['version'] !== NULL) {
if (count($datastream) == 1) { if (count($datastream) == 1) {
@ -354,7 +354,7 @@ function theme_islandora_datastream_edit_link(array $vars) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream); $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$can_edit = count($edit_registry) > 0 && islandora_datastream_access(FEDORA_METADATA_EDIT, $datastream); $can_edit = count($edit_registry) > 0 && islandora_datastream_access(ISLANDORA_METADATA_EDIT, $datastream);
return $can_edit ? return $can_edit ?
l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") : l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") :

Loading…
Cancel
Save