Browse Source

Use a toggle.

pull/677/head
Rosie Le Faive 8 years ago
parent
commit
8d8a97fccb
  1. 6
      includes/admin.form.inc
  2. 4
      includes/object_properties.form.inc
  3. 16
      islandora.install
  4. 15
      islandora.module

6
includes/admin.form.inc

@ -138,6 +138,12 @@ function islandora_repository_admin(array $form, array &$form_state) {
'#description' => t('During the ingest workflow, make the OBJ file upload step mandatory.'),
'#default_value' => variable_get('islandora_require_obj_upload', TRUE),
),
'islandora_deny_inactive_and_deleted' => array(
'#type' => 'checkbox',
'#title' => t('Lock down inactive and deleted objects.'),
'#description' => t('Deny access to inactive or deleted objects using a separate permission than for active objects.'),
'#default_value' => variable_get('islandora_deny_inactive_and_deleted', FALSE),
),
),
'islandora_namespace' => array(
'#type' => 'fieldset',

4
includes/object_properties.form.inc

@ -118,7 +118,7 @@ function islandora_object_properties_form_submit(array $form, array &$form_state
}
else {
// Confirm if user is about to lock themselves out of this object.
if (in_array($form_state['values']['object_state'], array('I', 'D'))) {
if (variable_get('islandora_deny_inactive_and_deleted', FALSE) && in_array($form_state['values']['object_state'], array('I', 'D'))) {
if ($form_state['object']->state == 'A') {
if (!user_access(ISLANDORA_ACCESS_INACTIVE_AND_DELETED_OBJECTS)) {
$form_state['islandora']['needs_confirmation'] = TRUE;
@ -240,7 +240,7 @@ function islandora_object_properties_regenerate_derivatives(array $form, array &
* @param array $form_state
* The Drupal form state.
*/
function islandora_object_properties_confirm_form(&$form_state) {
function islandora_object_properties_confirm_form(array &$form_state) {
$desc = t('You do not have permission to view Inactive or Deleted objects, so you will no longer be able to view or manage this object. Are you sure?');
$path = "islandora/object/{$form_state['object']->id}/manage/properties";
return confirm_form(array(),

16
islandora.install

@ -60,6 +60,7 @@ function islandora_uninstall() {
'islandora_require_obj_upload',
'islandora_breadcrumbs_backends',
'islandora_render_context_ingeststep',
'islandora_deny_inactive_and_deleted',
);
array_walk($variables, 'variable_del');
}
@ -132,18 +133,3 @@ function islandora_update_7001(&$sandbox) {
$t = get_t();
return $t("Islandora database updates complete");
}
/**
* Implements hook_update_N().
*
* Add default permissions for viewing inactive or deleted objects.
* Match permissions for viewing all objects.
*/
function islandora_update_7002(&$sandbox) {
$t = get_t();
return $t("A new permission 'view inactive or deleted objects' has been added
to the system, and these objects can no longer be viewed by someone without
this permission. If you have users who need to view inactive or deleted
objects please add the new permission to appropriate roles. This is
especially important for sites using the 'Islandora Simple Workflow' module");
}

15
islandora.module

@ -579,7 +579,7 @@ function islandora_theme() {
* Implements hook_permission().
*/
function islandora_permission() {
return array(
$permissions = array(
ISLANDORA_VIEW_OBJECTS => array(
'title' => t('View repository objects'),
'description' => t('View objects in the repository. Note: Fedora XACML security policies may override this permission.'),
@ -612,10 +612,6 @@ function islandora_permission() {
'title' => t('Revert datastream history'),
'description' => t('Revert to a previous version of a datastream.'),
),
ISLANDORA_ACCESS_INACTIVE_AND_DELETED_OBJECTS => array(
'title' => t('Access inactive and deleted objects'),
'description' => t('Access objects with a Fedora state of Inactive or Deleted'),
),
ISLANDORA_MANAGE_DELETED_OBJECTS => array(
'title' => t('Manage deleted objects'),
'description' => t('Purge or revert deleted objects.'),
@ -629,6 +625,13 @@ function islandora_permission() {
'description' => t('Add new datastream content as latest version.'),
),
);
if (variable_get('islandora_deny_inactive_and_deleted', FALSE)) {
$permissions[ISLANDORA_ACCESS_INACTIVE_AND_DELETED_OBJECTS] = array(
'title' => t('Access inactive and deleted objects'),
'description' => t('Access objects with a Fedora state of Inactive or Deleted.'),
);
}
return $permissions;
}
/**
@ -1690,7 +1693,7 @@ function islandora_object_access($op, $object, $user = NULL) {
*/
function islandora_islandora_object_access($op, $object, $user) {
module_load_include('inc', 'islandora', 'includes/utilities');
if ($object->state != 'A') {
if (($object->state != 'A') && variable_get('islandora_deny_inactive_and_deleted', FALSE)) {
return islandora_namespace_accessible($object->id) && user_access($op, $user) && user_access(ISLANDORA_ACCESS_INACTIVE_AND_DELETED_OBJECTS, $user);
}
else {

Loading…
Cancel
Save